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

Derek Parnell derek at psych.ward
Mon May 11 14:40:12 PDT 2009


On Mon, 11 May 2009 16:03:39 -0400, 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.

This is close to what we are going to do for the Euphoria language.
Currently, Euphoria does not allow assignment chaining (an assignment is
not an expression) so the proposed syntax is ...

  (mydic[x], mydic[y], mydic[z]) = length(mydic)

Plus that language evaluates the source expression before tackling the
target expression, so your idea is not unheared of.

-- 
Derek Parnell
Melbourne, Australia
skype: derek.j.parnell



More information about the Digitalmars-d mailing list