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

Jesse Phillips jessekphillips at gmail.com
Tue May 12 08:28:33 PDT 2009


On Sat, 09 May 2009 11:43:09 -0500, Andrei Alexandrescu wrote:

> If we want to get rid of newID, we'd write:
> 
>        writeln(dic.length, '\t', word);
>        dic[word] = dic.length;
> 
> by the Python rule, and
> 
>        writeln(dic.length, '\t', word);
>        dic[word] = dic.length - 1;
> 
> by the C# rule.
> 
> What's best?
> 
> 
> Andrei

Looking at it, I don't see dic[word] as increasing the length. Nothing 
has been added yet so why would it change? Ok, I realize a new location 
in memory has be reserved for storing a value, but at a glance it doesn't 
appear as though it is happening. You would also leave off the -1 if 
'word' was already in there.



More information about the Digitalmars-d mailing list