Re: Multiple Return Values - details fleshed out

2008-08-12 Thread David Green
On 2008-Aug-9, John M. Dlugosz wrote http://www.dlugosz.com/Perl6/web/return.html 
 to clarify and extrapolate from what is written in the Synopses:


Third, list assignment will handle assignment to a literal pair by  
accessing the names of the items inside the Capture. So list  
assignment behaves a lot like binding, but doesn’t do everything  
that parameter passing can do.

[...]
The example seen early on of (:$year,:$mon,:$mday) =  
localtime(time); can be made to work by returning both positional  
and named values. The return signature would need to have twice as  
many items, and the return statement would need to supply each one  
twice.



Couldn't these all work the same way as parameter passing does?  Even  
at the cost of a bit more complexity, it would be simpler overall to  
have only one set of rules to learn.




-David




Multiple Return Values - details fleshed out

2008-08-09 Thread John M. Dlugosz
I wrote http://www.dlugosz.com/Perl6/web/return.html to clarify and 
extrapolate from what is written in the Synopses.


--John


Re: Multiple Return Values - details fleshed out

2008-08-09 Thread Jon Lang
John M. Dlugosz wrote:
 I wrote http://www.dlugosz.com/Perl6/web/return.html to clarify and
 extrapolate from what is written in the Synopses.

A few comments:

1. I was under the impression that identifiers couldn't end with - or '.
2. While list context won't work with named return values, hash
context ought to.
3. The positional parameters of a Capture object essentially act as a
list with a user-defined index, don't they?  There _is_ some crossover
between the named parameter keys and the positional parameter
user-defined index, in that you ought to be able to provide a name and
have the Capture figure out which one you're asking for.  This works
because there should be no overlap between the keys of the hash and
the user-defined indices of the list.

-- 
Jonathan Dataweaver Lang