Re: The distinction between "do BLOCK while COND" and "EXPR while COND" should go
[email protected] (Tom Christiansen) Tue, 05 Sep 2000 10:08:32 -0600
| Newsgroups | perl.perl6.language.flow |
|---|---|
| Message-ID | <17659.968170112@chthon> |
>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