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

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

From:
Peter Scott
Date:
August 31, 2000 12:28
Subject:
Re: The distinction between "do BLOCK while COND" and "EXPRwhile COND" should go
Message ID:
4.3.2.7.2.20000831122713.00b69960@psdt.com
At 02:30 PM 8/31/00 -0500, Christopher J. Madsen wrote:
>Peter Scott writes:
>  > I dunno, maybe a last in a do block whose value is used by
>  > something should be a syntax error.  We're talking about code like
>  >
>  >     $x += do { $y = get_num; last if $y == 99; $y } while defined $y;
>  >
>  > right?  *Shudder*
>
>Yes, but we're also talking about code like
>
>   sub foo {
>     do {
>       ...
>       last unless $x;
>       ...
>     } while ($x < 20);
>   }
>
>Here, the return value of do is used as the return value of foo, but
>we may not actually care what foo returns.  Do you want to make that a
>syntax error?

AFAICT we could make it a syntax error iff foo is not used in void context; 
Perl must be able to tell whether or not it is used in order to know what 
context the result is in, right?

--
Peter Scott
Pacific Systems Design Technologies




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