develooper Front page | perl.perl6.language | Postings from November 2003

Re: Control flow variables

Thread Previous | Thread Next
From:
Luke Palmer
Date:
November 18, 2003 12:15
Subject:
Re: Control flow variables
Message ID:
20031118201526.GA30234@babylonia.flatirons.org
Austin Hastings writes:
> 
> 
> > -----Original Message-----
> > From: Michael Lazzaro [mailto:mlazzaro@cognitivity.com]
> > Sent: Tuesday, November 18, 2003 2:06 PM
> > To: perl6-language@perl.org
> > Subject: Re: Control flow variables
> >
> >
> >
> > On Tuesday, November 18, 2003, at 06:38 AM, Simon Cozens wrote:
> > > Given that we've introduced the concept of "if" having a return status:
> > >
> > >   my $result = if ($a) { $a } else { $b };
> > >
> >
> > Would that then imply that
> >
> >      sub blah {
> >        ...              # 1
> >        return if $a;    # 2
> >        ...              # 3
> >      }
> >
> > ...would return $a if $a was true, and fall through to (3) if it was
> > false?
> >
> 
> It sure should, provided there were a correct context waiting, which would
> quite nicely address another WIBNI thread a couple of months back about a
> quick return under those conditions.

Oh, and if you really want to do that return thing without using a
C<given>, you can just:

    sub blah {
        return $a || goto CONT;
    CONT:
        ...
    }

I don't see what's wrong with that. :-p

Luke

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