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

Nick Sabalausky a at a.a
Mon May 11 20:51:51 PDT 2009


"Rainer Deyke" <rainerd at eldwood.com> wrote in message 
news:guamfi$2b0d$1 at digitalmars.com...
> Nick Sabalausky wrote:
>> True, that's why I replied again and suggested something like:
>>
>> [mydic[x], mydic[y], mydic[z]].each = mydic.length;
>
> [[mydic[x], mydic[y], mydic[z]].each].each = mydic.length;
> [[[mydic[x], mydic[y], mydic[z]].each].each].each = mydic.length;
> [[[[mydic[x], mydic[y], mydic[z]].each].each].each].each = mydic.length;
> ...
>

I'm not sure what point you're trying to make here, but my idea is that 
"each" would basically be a write-only "extension property" (to borrow C# 
terminology) of array. So "each" wouldn't have a getter or a return value 
and therefore trying to stick its non-existant read/return value into an 
array literal (as you're doing above) would be an error.

>
> What's wrong with assignment chaining?  I'm amazed anybody would find
> chained assignment more confusing than unchained assignment.
>

I never said I had any problem with assignment chaining. I find them very 
straightforward (provided that their function-evaluation order is "rhs 
first, then lhs"). I'm just saying that if there's compelling reason to say 
"ok, assignments shouldn't be expressions", for the sake of simplifying 
certain aspects of the language, and would therefore be giving up 
assignment-chaining, then we wouldn't have to resort to temp-var and non-DRY 
methods to assign a single value to multiple targets.

...I suppose I was getting a little farther off-topic than I thought I was, 
maybe that's where the confusion came from. 





More information about the Digitalmars-d mailing list