4 ms·
> The way it currently works is arguably the way it should work, irrespective of the spec. The spec is how it should work, regardless of developer's opinions.
by jjnoakes 8y ago
> The way it currently works is arguably the way it should work, irrespective of the spec.
The spec is how it should work, regardless of developer's opinions.
> Why should [a] evaluate differently than [b]?
In my opinion (and I'm guessing in the opinion of the spec authors, though I can't be sure), saying "x += y" means "add y to x", so I'd expect the language to:
1) Figure out what "x" is once
2) Add "y" to it
Your opinion seems to be that saying "x += y" means "desugar to x = x + y" and you expect the language to:
1) Figure out what "x" is as a value
2) Add "y" to the value of "x"
3) Figure out what "x" is as a location (which may differ from 1)
4) Store the result into "x"
To me step 3 is very surprising, that "x" may differ, which is why I think the spec's definition is the more intuitive one (plus, it doesn't require knowledge of "desugaring" things).
- deleted 8y ago[deleted]