|
|
|
|
|
by kdmccormick
1020 days ago
|
|
That seems a little backwards and barbaric, though right? Imagine if we had to watch out for this as a common pitfall: // BUG! Actually subtracts x from current val of neg_x.
neg_x = -x;
Even moreso, how would these two lines behave? Would they differ in semantics? n = -5
n =- 5
Overall, -= is just so much less ambiguous.EDIT: To your point about ->, I personally think C would be better if: *p->next
parsed as: (*p)->next
instead of: *(p->next)
but maybe now I'm not thinking through all the parsing impliciations :) |
|
Regarding "n = -5", it would presumably be interpreted as "n=(-5)", same as today. Operators don't have spaces in them. So "n- -5" is "n-(-5)", rather than "n--5" (not valid).