Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make augmented assignments and assoc return their targets #870

Closed
wants to merge 2 commits into from

Conversation

refi64
Copy link
Contributor

@refi64 refi64 commented Aug 2, 2015

Ref #233, closes #238.

@gilch
Copy link
Member

gilch commented Aug 2, 2015

This breaks augmented slice assignments.
Current:

=> (setv spam (* 10 [0]))
spam = (10 * [0])
=> spam
spam
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
=> (print (+= (slice spam 2 5)[1 2 3]))
spam[2:5] += [1, 2, 3]
print(None)
None
=> spam
spam
[0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 0, 0, 0]

Proposed:

=> (setv spam (* 10 [0]))
spam = (10 * [0])
=> spam
spam
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
=> (print (+= (slice spam 2 5)[1 2 3]))
spam[2:5] += [1, 2, 3]
print(_hy_anon_var_1)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
NameError: name '_hy_anon_var_1' is not defined
=> spam
spam
[0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 0, 0, 0]

Similarly breaks augmented subscript assignments:

=> (print (+= (get spam 0) 12))
spam[0] += 12
print(_hy_anon_var_1)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
NameError: name '_hy_anon_var_1' is not defined

And augmented attribute assignments:

=> (setv foo (lambda [] nil))
foo = (lambda : None)
=> (setv foo.bar 2)
foo.bar = 2
foo.bar
2
=> (print (+= foo.bar 1))
foo.bar += 1
print(_hy_anon_var_1)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
NameError: name '_hy_anon_var_1' is not defined

@paultag
Copy link
Member

paultag commented Dec 12, 2015

@gilch @kirbyfan64 what's the status of this? Can we update against master and address feedback?

Please re-open once it's updated!

@paultag paultag closed this Dec 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Assoc returning the dict
3 participants