develooper Front page | perl.perl6.language.flow | Postings from September 2000

Re: The distinction between "do BLOCK while COND" and "EXPRwhile COND" should go

From:
Nathan Torkington
Date:
September 5, 2000 09:08
Subject:
Re: The distinction between "do BLOCK while COND" and "EXPRwhile COND" should go
Message ID:
14773.6738.893119.992419@prometheus.frii.com
Peter Scott writes:
> 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?

Context of subroutine calls isn't known until runtime:

  $x = f();	# scalar
  @x = f();	# list

The warning you're talking about is a compiletime warning.

Nat



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About