Re: Generic symbolic sequence assignment

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

This whole assignment thing is getting out of hand.

According to the manual (and how much user-code?)

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

Surely you don't want to break something as basic as that merely to have multiple and/or generic assignment!

This would still work. The expression you mentioned is a RHS value. There is no LHS value there:

s = {a,b,c} = {d,e,f} 
-- s is {a=d, b=e, c=f} 
 
{a, b, c } = { d, e, f} 
-- a is assigned the value of d 
-- b is assigned the value of e 
-- c is assigned the value of f 

In any case, these literal examples are useful for describing what happens, but would not be the most common way they would actually be used. The real utility comes from functions that return multiple results. This avoids the need to store the result, then break out the values, like this:

-- old way: 
s = value( x ) 
success = s[1] 
val     = s[2] 
 
-- new way: 
{success, val} = value( x ) 

Matt

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

Search



Quick Links

User menu

Not signed in.

Misc Menu