Skip to content
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

Clarify documentation #17147

Closed
p5pRT opened this issue Sep 6, 2019 · 6 comments
Closed

Clarify documentation #17147

p5pRT opened this issue Sep 6, 2019 · 6 comments

Comments

@p5pRT
Copy link

p5pRT commented Sep 6, 2019

Migrated from rt.perl.org#134411 (status was 'open')

Searchable as RT134411$

@p5pRT
Copy link
Author

p5pRT commented Sep 6, 2019

From @KES777

Hi.

Question about localization raises for this case​: https://stackoverflow.com/q/57821354/4632019
```
my $field;
for $field ( qw' email phone name ' ) {
  last if $user->$field =~ /$search/;
}
print $field; # undef
```

In the attachment I suggest to clarify DOC a bit

--
Best regards,
Eugen Konkov

@p5pRT
Copy link
Author

p5pRT commented Sep 6, 2019

From @KES777

0001-Clarify-documentation.patch
From 8ad82c690492a96c443d9b4ad8bbb80755a00bdf Mon Sep 17 00:00:00 2001
From: Eugen Konkov <kes-kes@yandex.ru>
Date: Fri, 6 Sep 2019 15:06:38 +0300
Subject: [PATCH] Clarify documentation

Currently `foreach` and `for` loops are synonyms. Thus implicit localization
occurs not only for `foreach`. This change clarifies that implicit
localization occurs depending on style
---
 pod/perlsyn.pod | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/pod/perlsyn.pod b/pod/perlsyn.pod
index 02cfb73b1a..6f57838c42 100644
--- a/pod/perlsyn.pod
+++ b/pod/perlsyn.pod
@@ -496,8 +496,7 @@ is therefore visible only within the loop.  Otherwise, the variable is
 implicitly local to the loop and regains its former value upon exiting
 the loop.  If the variable was previously declared with C<my>, it uses
 that variable instead of the global one, but it's still localized to
-the loop.  This implicit localization occurs I<only> in a C<foreach>
-loop.
+the loop.  This implicit localization occurs I<only> for non C-style loop
 X<my> X<local>
 
 The C<foreach> keyword is actually a synonym for the C<for> keyword, so
-- 
2.23.0

@p5pRT
Copy link
Author

p5pRT commented Oct 5, 2019

From @jkeenan

On Fri, 06 Sep 2019 12​:20​:18 GMT, kes-kes@​yandex.ru wrote​:

Hi.

Question about localization raises for this case​:
https://stackoverflow.com/q/57821354/4632019
```
my $field;
for $field ( qw' email phone name ' ) {
last if $user->$field =~ /$search/;
}
print $field; # undef
```

In the attachment I suggest to clarify DOC a bit

Thank you for your suggestion. However, I don't think it improves the current documentation (which, except for a spelling correction, has existed in the current form since 2003). The text in question occurs in a paragraph clearly headed "Foreach Loops". There's nothing else in this paragraph about C-style 'for' loops, so I think adding something about 'non-C-style "for" loops' isn't helpful.

My two cents.

Thank you very much.
--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Oct 5, 2019

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Oct 9, 2019

From @iabyn

On Sat, Oct 05, 2019 at 03​:12​:28PM -0700, James E Keenan via RT wrote​:

On Fri, 06 Sep 2019 12​:20​:18 GMT, kes-kes@​yandex.ru wrote​:

Hi.

Question about localization raises for this case​:
https://stackoverflow.com/q/57821354/4632019
```
my $field;
for $field ( qw' email phone name ' ) {
last if $user->$field =~ /$search/;
}
print $field; # undef
```

In the attachment I suggest to clarify DOC a bit

Thank you for your suggestion. However, I don't think it improves the
current documentation (which, except for a spelling correction, has
existed in the current form since 2003). The text in question occurs in
a paragraph clearly headed "Foreach Loops". There's nothing else in
this paragraph about C-style 'for' loops, so I think adding something
about 'non-C-style "for" loops' isn't helpful.

'for' is a synonym for 'foreach'. Whether its a C-style or not isn't
decided by the choice of keyword, but rather by the presence of semicolons
in the list. So I think this patch is an improvement.

--
"Emacs isn't a bad OS once you get used to it.
It just lacks a decent editor."

@khwilliamson
Copy link
Contributor

Applied as 73bc018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants