On Sep 6, 2008, at 10:51 AM, Larry Wall wrote:
On Sat, Sep 06, 2008 at 11:38:42AM -0500, John M. Dlugosz wrote:
The when statements are just like if statements. After executing
one,
it goes on to the following statement which does not have to be a
conditional statement. That is, you can mix when statements with
plain
unconditional statements.
If multiple when conditions match, it runs all of them. It's more
like
if statements, not like a C switch statement.
No, when statements also imply a break at the end of the block. It
should never run more than one (unless you explicitly say "continue").
You can mix unconditional statements, but any after the first matching
when will not be run (unless you say "continue").
If both "when *" and "default" are running, it's a small bug,
indicating that the "when * {...}" got turned into a mere "{...}"
or "..." on the assumption that you don't actually have to test for
the default condition. Which you don't, but it should still run
only one default block, so it should really turn into something like
"{...; break}".
I've set up two identical when blocks, followed by a when * and a
default and all of them run, which is consistent with the behavior
that John describes. The current behavior is no different from a if
EXPR block which is shorter to type, so I'm glad that the intended
behavior is to break out on success.
Patrick merged this with #57652, and there is a comment in the code
that marks this behavioral problem as a todo (in src/parser/actions.pm).
Stephen Simmons
Larry