Open mpmilano opened 11 years ago
Our destructuring assignment really only works with tuples of literals, I think.
I played with that a little bit last week; to do it right we really need to define an entire tree-walk over LHS expressions, and build an AST that exercises a tree of iterators on the right. It's hairy stuff:
def f(): ... yield 'fun' ... yield 'times' ... [(a,b),(c,d)] = {f(), f()} a 'fun' b 'times' c 'fun' d 'times'
On Thu, Mar 28, 2013 at 1:24 AM, Matthew Milano notifications@github.comwrote:
class c: pass c.x, c.y = (5,6)
reports exception: can't assign to literals
this works in python. This makes solving the destructuring bind bug for classes somewhat tricky. I've worked around it, but when this is solved I'l like to remove the workaround.
— Reply to this email directly or view it on GitHubhttps://github.com/brownplt/lambda-py/issues/58 .
For the ambitious, I bet you can probably segfault Python somewhere in here by using an LHS that has a property that calls a generator that's in the middle of an iteration on the RHS or something similarly insane.
On Thu, Mar 28, 2013 at 1:35 AM, Joe Gibbs Politz joe@cs.brown.edu wrote:
Our destructuring assignment really only works with tuples of literals, I think.
I played with that a little bit last week; to do it right we really need to define an entire tree-walk over LHS expressions, and build an AST that exercises a tree of iterators on the right. It's hairy stuff:
def f(): ... yield 'fun' ... yield 'times' ... [(a,b),(c,d)] = {f(), f()} a 'fun' b 'times' c 'fun' d 'times'
On Thu, Mar 28, 2013 at 1:24 AM, Matthew Milano notifications@github.comwrote:
class c: pass c.x, c.y = (5,6)
reports exception: can't assign to literals
this works in python. This makes solving the destructuring bind bug for classes somewhat tricky. I've worked around it, but when this is solved I'l like to remove the workaround.
— Reply to this email directly or view it on GitHubhttps://github.com/brownplt/lambda-py/issues/58 .
class c: pass c.x, c.y = (5,6)
reports exception: can't assign to literals
this works in python. This makes solving the destructuring bind bug for classes somewhat tricky. I've worked around it, but when this is solved I'l like to remove the workaround.