Re: pbr vs multiple returns

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

Chris Bensler wrote:

My apologies for the recent (part 4) post.

> Also, regarding multiple return values. What is the purpose of providing an
> alternate syntax for multiple return values?
> I don't see the purpose of introducing a new syntax to declare that a 
> function returns multiple values. We can already do that by returning a 
> sequence.
You are quite right. After considering this a bit more, I think I was trying to
avoid creating the "wrapper" sequence for the return values but actually if the
last time I returned {x,y} it put x in one variable and y in another, the
previous "{,}" should still be sitting there with a refcount of 1 ready for
re-use anyway.

> All
> we need is a syntax for how to assign the members of a returned sequence to
> multiple variables.
> 
> {err,val} = get("3.14")
> 
> Shouldn't that be a viable statement without having to modify how get() 
> works?
Yep. While this means we no longer need #=, as a separate and lesser issue you
might still want @= (pronounced all equal), so that:
{x,y}@="chris"

sets both x and y to "chris" rather than x to 'c' and y to 'h'. Same deal of
course with {x,y} at =get_name().

Regards,
Pete

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

Search



Quick Links

User menu

Not signed in.

Misc Menu