assignment: left-to-right or right-to-left evaluation?
Sergey Gromov
snake.scaly at gmail.com
Sun Jun 21 17:30:32 PDT 2009
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?
If you use the Python rule you can rewrite
dic[word] = dic.length;
as
dic.opIndexAssign(word, dic.length);
By the C# rule you cannot do without opIndexForAssignment sort of thing.
It's not a matter of best/worse IMO, it's a matter of feasible/not
feasible.
More information about the Digitalmars-d
mailing list