coming from a c++ background, I constantly type break instead of last only
to be scolded by the syntax checker.  If my faubles result in incorrectly
executing program ( a mysterious error at that!) then I and many other C++
programmers will waste a lot of time hunting down a trivial bug.  I
understand the need for an implied given, but when faced with code like:

for @foo -> $bar {
  when /this/ { ... break; ... }
  when /that/ => { ... last; ... }
  when /the other/ => { ... next; ...  }
}

I get really jittery...To me, it looks like they affect the loop, but
instead one affects an implied given and the others affect the loop.
This should at least be a very stern warning.

Secondly,

for @list -> ($bar, $baz) {
  when /this/ { ... }
}

is this equivalent to
if( ($bar, $baz) =~ /this/ ) { ... }

if so, what does that mean?

Finally,

if the correct syntax is:

for $a, $b -> $c, $d

then I would like to say that while this does mimic the C<my> syntax, it
doesn't put identifiers and their values close to each other like

for $a -> $c,
     $b -> $d

does.  This is not to be construed as a bad thing...in fact, it might
promote people to not use the C< -> > for more than two or three values.

Tanton
----- Original Message -----
From: "Austin Hastings" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, February 25, 2002 3:43 PM
Subject: Re: Loop exiting


> Currently,
>
> given $foo -> $bar
> {
> }
>
> can be thought of as
>
> foreach my $bar ($foo)
> {
> }
>
> Given the way people with expectations will interpret break, setting
> break === last seems like the right thing to do.
>
> =Austin
>
> --- Larry Wall <[EMAIL PROTECTED]> wrote:
> > [EMAIL PROTECTED] writes:
> > : --- Larry Wall <[EMAIL PROTECTED]> wrote:
> > : > Simon Cozens writes:
> > : > : Larry Wall:
> > : > : > Not the same concept exactly.  I think a C<break> within a
> > C<for>
> > : > loop
> > : > : > would be the same as a C<next>, not a C<last>.
> > : > :
> > : > : Doesn't this break C and Shell resonance?
> > : >
> > : > We've done that before.  :-)
> > :
> > : Umm, doesn't break translate basically as "leave, now" rather than
> > as
> > : "hop to the loop nexus and consider leaving"?
> >
> > Sure, but it means "leave the switch now", not "leave the loop now".
> >
> > : What's your thinking in equating break w/ next?
> >
> > Only that
> >
> >     for @foo {
> > ...
> >     }
> >
> > can be thought of as shorthand for
> >
> >     for @foo -> $temp {
> > given $temp {
> >     ...
> > }
> >     }
> >
> > I am also assuming that the break is only meaningful as a switch
> > control,
> > not a loop control.  But I can see where it would be confusing.
> > Perhaps
> > C<break> should be illegal inside a C<for>, and the user forced to
> > choose
> > between C<next> and C<last>.
> >
> > Larry
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Sports - Coverage of the 2002 Olympic Games
> http://sports.yahoo.com
>

Reply via email to