David Storrs writes:
> On Fri, Oct 24, 2003 at 12:57:18AM -0600, Luke Palmer wrote:
> > Presuming you can do:
> >
> > (who => $name, why => $reason) := (why => $because, who => "me");
> >
> > (from A6)
> >
> > Does that imply that you can do:
> >
> > sub routine (name => $nombre, date => $fecha) {...}
> >
> > Anyway, I just realized that this is finally an elegant way to do
> > multiple, unordered return values:
> >
> > (name => $name, id => $id) := getinfo();
> >
> > (Or, in this precise case:)
> >
> > (+$name, +$id) := getinfo();
>
>
> Just confirming something...if you did this:
>
> ($name, $id) := &getinfo();
>
> I think you would end up storing an alias to the getinfo() sub in $name, and
> undef in $id. Is that correct?
Yeah, providing getinfo has an empty sig.
Well, if we take the binding/parameter passing equivalency a little
farther, that can be an error. Which may turn out to be good:
($name, $id) := getinfo();# I want getinfo to return 2 values
($name, ?$id) := getinfo(); # I realize that it may only return 1
Etc.
> What would happen if you did this?
>
> (+$name, +$id) := &getinfo();
>
> I would expect a compile time error, because you can't bind a sub
> alias to a scalar that is being forced into numeric context.
Nu...meric context? I meant that as named parameters, that is,
expecting getinfo to return a list of pairs. So I think that will be an
error, just for a different reason.
Luke