Re: Multi-assign

new topic     » goto parent     » topic index » view thread      » older message » newer message
DerekParnell said...
Fernando said...

Some interesting possibilities with LHS symbolic sequences:

  • Initializing several variables with the same value:
{a,b,c} = 0

When the RHS is an atom, we might be able to get away with this, but once the RHS is a sequence, we strike ambiguities.

Consider ...

{a,b,c} = 1       -- Assign 1 to a, b, and c 
{a,b,c} = {d,e,f} -- Assign {d,e,f} to a, b, and c or 
                  -- assign d to a, e to b, and f to c? 

IMHO, one of the intentions of multi-assign is to simplify the access to the elements of a returned sequence of a function. Then:

{a,b,c} = {d,e,f} -- assign d to a, e to b, and f to c

To satisfy the other case:

{a,b,c} = { {d,e,f} , {d,e,f} , {d,e,f} } 

- Fernando

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu