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

Jarrett Billingsley jarrett.billingsley at gmail.com
Mon May 11 21:49:44 PDT 2009


On Mon, May 11, 2009 at 11:34 AM, Steven Schveighoffer
<schveiguy at yahoo.com> wrote:

>> Funny, I vastly prefer the latter to the former.  Having more than one
>> thing happen on one line is very difficult to read after having
>> written it, for me.
>
> So I take it if you have many function calls, or chained function calls, you
> split them out into separate lines? :P
>
> fun(gun(123)).xyz() =>
>
> auto tmp1 = gun(123);
> auto tmp2 = fun(tmp1);
> tmp2.xyz();
>
> ???
>
> I look at chained assignment as no different.

No.  Nested function calls are incredibly common and do not (usually!)
have side effects; it's not very different from other algebraic
expressions.  Chained method calls are still fairly common.  It's
incredibly rare that I have to assign the same value to multiple
targets, and when I do, the little time I could save by not typing the
second assignment is offset by the increased time it takes me to look
for assignments to a variable when I come back to the code later.

It's much more of an argument of my brain not being trained to parse
it due to its low incidence than anything else :P



More information about the Digitalmars-d mailing list