assignment: left-to-right or right-to-left evaluation?
Michiel Helvensteijn
m.helvensteijn.remove at gmail.com
Mon May 11 13:18:13 PDT 2009
Nick Sabalausky wrote:
> I was giving a little bit of thought to assignment chaining the other day.
> Unless someone can point out why I'm wrong, I think some of the
> functional-style stuff we've been getting into can make assignment
> chaining obsolete.
>
> Hypothetical example:
> [mydic[x], mydic[y], mydic[z]].fill(mydic.length);
>
> I think something like that would be more clear than both the "tmp" and
> assignment chaining versions, and perhaps allow any language complexities
> that arise from the assignment chaining feature to be removed.
Seriously?
[mydic[x], mydic[y], mydic[z]].fill(mydic.length);,
I admit, is not bad, but it's certainly not easier on the eyes than
mydic[x] = mydic[y] = mydic[z] = mydic.length;.
And you need a good optimizing compiler to get the same speed. Plus, doesn't
it suffer from the same problems as the assignment-chaining version? If x,
y and/or z are not already in mydic, which mydic.length are you using
there?
--
Michiel Helvensteijn
More information about the Digitalmars-d
mailing list