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

Allow compound assignment with all binary operators #28357

Closed
DeidreHouse opened this issue Jul 30, 2018 · 2 comments
Closed

Allow compound assignment with all binary operators #28357

DeidreHouse opened this issue Jul 30, 2018 · 2 comments
Labels
parser Language parsing and surface syntax speculative Whether the change will be implemented is speculative

Comments

@DeidreHouse
Copy link

I noticed that compound assignment won't work with certain operators, like |> and ∘.

For example, the following code gives the error "ERROR: syntax: unexpected "="" on line 2:

a = 2
a |>= exp 

But if I say, redefine the * operator as |>, it works perfectly:

import Base.*
* = |>
a = 2
a *= exp

outputs 7.389, as it should. The same thing happens with the function composition operator. So clearly the language is able to do this, the parser just doesn't handle it properly with all operators. I tried this in both 0.6.4 and 0.7 and got the same results. Is there some deeper reason why this doesn't currently work?

@stevengj
Copy link
Member

It's not really a "deep" reason, but right now the parser code uses an explicit list of assignment operators and a corresponding explicit list of lowering rules. It's impractical to extend this approach to all possible binary operators, so some surgery on the parsing/lowering code would be required.

@stevengj stevengj added parser Language parsing and surface syntax speculative Whether the change will be implemented is speculative labels Jul 30, 2018
@JeffBezanson
Copy link
Sponsor Member

duplicate of #15964

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parser Language parsing and surface syntax speculative Whether the change will be implemented is speculative
Projects
None yet
Development

No branches or pull requests

3 participants