assignment: left-to-right or right-to-left evaluation?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri May 15 18:59:35 PDT 2009


bearophile wrote:
> Georg Wrede:
> 
>> arra[i] = arrb[i++];
>> arra[i++] = arrb[i];
>> I'm not sure that such dependences are good code.
>> By stating a definite order between lvalue and rvalue, you
>> would actually encourage this kind of code.
> 
> I agree that putting such things in code is bad, but nowadays the solution adopted by C is Just Wrong. To help avoid bugs from your programs the language has to avoid undefined behaviors (this is one of the lessons of Java).
> So the solutions are to define such behaviors as Andrei suggests, or to forbid such code. I can accept both ways.
> I am used to Python and I think I can appreciate the Python solution better, but the Java solution too is better than having undefined behavior in a modern language.
> So thank you Andrei for this work.

Well put! Java has definitely taught us that a clean, robust language 
definition can go a long way. (And also that marketing helps :o)).

I think Java is a bit like the STL in a certain respect: there's a 
feeling of "before" and "after". Java has shown not only that defined 
behavior is good, but also that it can be incorporated into a practical 
language.

Andrei



More information about the Digitalmars-d mailing list