develooper Front page | perl.perl6.language | Postings from February 2001

Re: assign to magic name-of-function variable instead of "return"

Thread Previous | Thread Next
From:
John Porter
Date:
February 5, 2001 06:39
Subject:
Re: assign to magic name-of-function variable instead of "return"
Message ID:
20010205093904.B16968@min.net
James Mastros wrote:
> 
> Oh, here's an idea WRT extending the concept to cover both scalar and list
> assignment:  Have $^R be the return in scalar context, and @^R be the return
> in list context.  If @^R is unset, then a one-element list of $^R is returned.

I don't like where this is leading.  Currently perl does not allow
modification of lists (vs. arrays).  The operations supported for
lists are a tiny subset of those supported for arrays: assignment-from,
single-item index, and last-element-of.  Simply setting up an array
alias to a list won't magically give us all those array operations
for the list.  In order to C< push @^R >, there has to be a data
structure there that supports the push operator.  And if that is
going to be the case, then I don't see the point in all this over
having your own array variable and returning that when you're done.

-- 
John Porter

You can't keep Perl6 Perl5.


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About