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.





-- 
                      David Nicol 816.235.1187 [EMAIL PROTECTED]
                          "gorkulator borked.  Please investigate."

Reply via email to