On Thu, Feb 01, 2001 at 07:12:31PM -0600, David L. Nicol wrote:
>
>
> Looking over some C code of the form
>
>
> int fname(char *param){
> int rval;
> ...
> return(rval);
> }
>
> I recalled hearing about a language (was it java?) where
> you set the return value of a function (was it VB?) by
> assigning to the name of the function within the function body,
> so the last line would be
>
> fname=rval;
>
> or fname could be used instead of rval all through it.
>
> This obviously allows the compile-time optimization of using the
> lvalue the function will be getting assigned to directly, one fewer
> temporary storage space, as well as saving keystrokes.
>
> Did anyone ever (before) suggest adding this to perl? It would mean
> that
>
> sub subname(proto){
>
> # in here, the bareword "subname" is a magic
> # alias for the lvalue this routine is getting
> # assigned to, if any.
>
> }
>
> 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.
Does that mean there's going to be a @__ as well, for uses in list context?
If so, what happens with:
sub some_sub {
@__ = qw /foo bar baz/;
}
my $fnord = some_sub;
If there isn't going to be a @__ of some sorts, how is the case of the sub
being called in list context going to be handled?
Abigail