Front page | perl.perl5.porters |
Postings from June 2011
RFC: Make break last
Thread Next
From:
Johan Vromans
Date:
June 13, 2011 10:51
Subject:
RFC: Make break last
Message ID:
m2aadlzkju.fsf@phoenix.squirrel.nl
When feature 'switch' is enabled, the keyword 'break' is added to the
language. 'break' can only be used in one place: in a 'given' block.
There it terminates the block.
Looping blocks already had a means to do so: 'last'.
Basically, 'break' is just like 'last' except that it can only be used
in a 'given' block.
I propose to make 'break' and 'last' the same.
Actually I'd preferred to not have 'break' at all, since 'last' is
perfectly equipped to do the job. The only thing necessary for this is
to make 'given' a looping block.
LABEL:
given ( ... ) {
...;
when ( ... ) { ... }
...;
last if ...;
}
continue { ... }
No doubt, some day someone will find interesting applications for
'next', 'retry' and the 'continue' block.
The question is: does 'break' have added value. The answer is "yes". For
example:
while ( ... ) {
given ( ... ) {
...;
last if ...;
break if ...;
...;
}
# here if broken
...;
}
# here if lasted
However I think this is contrived ad absurdum.
For all practical means, 'given' can be a looping block, and 'break' can
be just 'last'.
-- Johan
Thread Next
-
RFC: Make break last
by Johan Vromans