Should the comma operator be removed in D2?

Yigal Chripun yigal100 at gmail.com
Wed Nov 18 14:10:51 PST 2009


Stewart Gordon wrote:
> Yigal Chripun wrote:
> <snip>
>> the only use case that will break is if the two increments are 
>> dependent on the order (unless tuples are also evaluated from left to 
>> right):
>> e.g.
>> a + 5, b + a //
> <snip>
> 
> If you're overloading the + operator to have an externally visible side 
> effect, you're probably obfuscating your code whether you use the comma 
> operator or not.
> 
> Moreover, how can you prove that nothing that uses the operator's return 
> value can constitute a use case?
> 
> Stewart.

I don't follow you. What I said was that if you have the above in a for 
loop with a comma expression, you'd expect to *first* add 5 to a and 
*then* add the new a to b (comma operator defines left to right order of 
evaluation).
tuples in general do not have to require a specific order since you keep 
all the results anyway, so the above could break. by defining tuples to 
be evaluated with the same order, the problem would be solved.



More information about the Digitalmars-d mailing list