-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Inconsistencies with available assignment operators #56821
Comments
These are probably just missing from the list in the parser, might as well have them. |
It's quite clever, because it's consistent with the ordinary meaning of our infix update, but I do worry it's a bit too magical. |
I vote no, please, to |
Is there a reason not to just have assignment operators for every infix operator where it wouldn't cause ambiguity? (That is, not |
I guess define "ambiguous" ? I don't think any of us want to see |
Simplest in my mind would be to make an equivalent assignment operator for every operator that's an actual function, so excluding"control flow" that's effectively not evaluated like an infix operator ( For reference, the available assignment operators at present seem to be:
As well as |
That looks like an oversight; we should just add them. |
Would also love to have |
I agree all of those are super reasonable; my being a hater extends only to |
Most of the basic "arithmetic" operators support assignment operators, where something like
a += 5
is equivalent toa = a + 5
. However, the presence of these seems to be somewhat inconsistent and a couple useful use-cases are missing. One use case I've ran into recently, when working with immutable structures, is wanting to update the value of a variable in-place in a similar fashion, but when applying arbitrary functions. For instance, something likeor even
The
|>
operator makes the latter a bit nicer to express, asBut it would be convenient to be able to do something like
or the like instead. Furthermore, there are inconsistencies even among the more "normal" infix operators in terms of which support assignment operators; while
⊼
,⊽
, and⊻
are all infix operators (giving bitwise nand, nor, and xor respectively), only⊻=
is a valid assignment operator, which feels wacky.The text was updated successfully, but these errors were encountered: