develooper Front page | perl.perl6.language | Postings from October 2002

Re: labeled if blocks

Thread Previous | Thread Next
From:
Marco Baringer
Date:
October 27, 2002 03:58
Subject:
Re: labeled if blocks
Message ID:
m2wuo46qn5.fsf@bese.it
"Steve Canfield" <canfieldsteve@hotmail.com> writes:

> Will Perl6 have labeled if blocks?  Like this:
> 
>   BLAH:
>   if ($foo) {
>      ...
>      last BLAH if $bar;
>      ...
>   }

why not use -> to create a sub which you can return from?

if $foo -> {
  ...
  return if $bar;
  ...
}

this of course means you can't directly return from the sub (or whatever) in
which the if (or given or while or for) is nested...

slightly related:

what happens to the return value of the subs passed to for, if, while
and given statements? (what does '$foo = if $bar { ... } else { ... }'
do?)

-- 
-Marco
Ring the bells that still can ring.
Forget your perfect offering.
There is a crack in everything.
That's how the light gets in.
     -Leonard Cohen


Thread Previous | Thread Next


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