David L. Nicol wrote:
>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.
>
>sub subname(proto){
># in here, the bareword "subname" is a magic
># alias for the lvalue this routine is getting
># assigned to, if any.
>}
If you really need the speed, why don't you try:
sub subname(\$;proto) {
my $result = shift;
# in here, the lvalue `$$result' is a not-magic
# alias for the lvalue this routine is supposed
# to assign a value to.
}
Then do s#$var = subname(@args)#subname($var, @args)#g in your code. It will
give you `source-code-time' optimization of using the lvalue the function
will be assigning to directly, also one fewer temporary storage space, and I
don't really see how your first proposal would save keystrokes, by replacing
`return $x;' with `MyReallyLongishAndBloodyIdiotSubName = $x; last
MyReallyLongishAndBloodyIdiotSubName; # must type this to get out of the
sub'. Anyway, I always recommend to learn to type fast, it ain't hard (just
kidding... ;-)
- Branden