>Hey, waitaminute.  That isn't a list in sub fn in the first place; it's 
>three expressions separated by scalar commas.  Why is there no complaint 
>about useless use of a constant in void context?

>$ perl -Mstrict -wle 'sub f{return(3,5,7)} my $x = f()'
>$ perl -Mstrict -wle 'my $x = (3,5,7)'
>Useless use of a constant in void context at -e line 1.
>Useless use of a constant in void context at -e line 1.
>$

>If context propagates through subroutine calls why no warning?

Because the compiler doesn't know that f() will only be called
in scalar context.  It might be called in list context from
a separate compilation unit.  Thus, this is deferred until runtime.

--tom

Reply via email to