in reply to Re^2: How does 'goto LABEL' search for its label?
in thread How does 'goto LABEL' search for its label?
I sympathized with the "yow" remark because it looked like the difference between finding the label and not finding the label was whether "return" was used. But that was a red herring.
The real difference is whether the one-liner ends with "G" or with "F". The inclusion of the 'return' keyword makes no difference (but lacking the 'return' when calling "F" makes the reason for the output less obvious).
Once I noticed the single-character difference off at the end of the long lines, then I lost sympathy for a "yow" response because the behavior is exactly as I would have expected from the documentation. And, it seems a reasonable restriction.
Now, I think using 'goto' to leave a subroutine is a rather squirrely technique. I would much prefer that it produced a warning so you'd have to write such squirrely code more like:
sub F { return G(); LF: say 6; } sub G { say 2; no warnings 'exiting'; goto LF; } G();
Indeed, I'm not sure why the -w you used fails to trigger this:
=item Exiting subroutine via %s (W exiting) You are exiting a subroutine by unconventional means, such as a goto, or a loop control statement.
- tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How does 'goto LABEL' search for its label? (yow?)
by LanX (Saint) on Jan 17, 2013 at 03:58 UTC | |
by tye (Sage) on Jan 17, 2013 at 04:07 UTC | |
by LanX (Saint) on Jan 17, 2013 at 04:11 UTC | |
|
Re^4: How does 'goto LABEL' search for its label? (yow?)
by Anonymous Monk on Jan 17, 2013 at 03:06 UTC |