-
Notifications
You must be signed in to change notification settings - Fork 583
[doc] perlsyn: mention something about multiple identical labels #18369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
On 11/29/20 7:39 PM, 積丹尼 Dan Jacobson wrote:
On perlsyn, around
The LABEL is optional, and if present, consists of an identifier
followed by a colon. The LABEL identifies the loop for the loop control
statements "next", "last", and "redo".
do say something like "If more than one label with the same name occurs, it
refers to the nearest one above it".
As there is no error in doing e.g., this,
|L: while ( $_ = shift @PIDS ) { my $c = -1; L: for my $genre ***@***.***)
{ $c++; L: if ( $genre->{Exclude} && $$p{$_}{title} =~
/$genre->{Exclude}/i ) { next; } else { L: for my $match ( @{
$genre->{Matches} } ) { if ( $$p{$_}{title} =~ /$match/i ) { push @{
$genre->{Playlists} }, $_; next L; } } L: for my $match ( @{
$genre->{Matches} } ) { if ( $$p{$_}{title} =~ /$match/i ) { push @{
$genre->{Playlists} }, $_; next L; } } } } } |
But the document don't say what multiple identical labels are supposed
to do. It only goes on to mention the case of no label at all,
If the LABEL is omitted, the loop control statement refers to the
innermost enclosing loop.
And even cautions,
This may include dynamically looking back your call- stack at run time
to find the LABEL. Such desperate behavior triggers a warning if you
use the "use warnings" pragma or the -w flag.
But still never touches on multiple identical label cases.
"Why would anybody add multiple identical labels, even on the same block
level?"
That's not a concern of me. I'm just saying the document needs to say
what will happen... or errors should be triggered.
If we're going to add this documentation, we should first add tests to
the test suite (perhaps to t/op/loopctl.t) which demonstrates these cases.
|
Here's how I discovered this documentation bug: |
On perlsyn, around
do say something like "If more than one label with the same name occurs, it
refers to the nearest one above it".
As there is no error in doing e.g., this,
But the document don't say what multiple identical labels are supposed
to do. It only goes on to mention the case of no label at all,
And even cautions,
But still never touches on multiple identical label cases.
"Why would anybody add multiple identical labels, even on the same block
level?"
That's not a concern of me. I'm just saying the document needs to say
what will happen... or errors should be triggered.
The text was updated successfully, but these errors were encountered: