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:
David L. Nicol
Date:
February 1, 2001 17:37
Subject:
Re: assign to magic name-of-function variable instead of "return"
Message ID:
3A7A0F3B.BC7823BD@kasey.umkc.edu
"David L. Nicol" wrote:

> We could even define a new line noise variable which could hold the
> results of the last name-of-function subroutine that was not invoked
> as an rvalue (I nominate $__ ); make such an invokation a warning-level
> offense; and make $__ visibility/localization compatible with recursion.


To answer my own question, the thing I found annoying about the syntax
when it was shown to me was that it seemed to break portability: you can't
cut from a function called A that returns something by assigning to A and
paste into a function called B to get the same functionality.  So a way
to have the feature (direct assignment to external lvalue) and maintain
portability might be to forget about magic names and just make the new
LNV (which I am calling $__ in this thread) mean "An alias for the
L-value of what the subroutine return value will get assigned to, or
${undef} if we're not invoked as an R-value."  so ${undef} gets autolocalized
if used.


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