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

perlref’s sections are a little muddled #15362

Closed
p5pRT opened this issue May 26, 2016 · 8 comments
Closed

perlref’s sections are a little muddled #15362

p5pRT opened this issue May 26, 2016 · 8 comments

Comments

@p5pRT
Copy link

p5pRT commented May 26, 2016

Migrated from rt.perl.org#128250 (status was 'resolved')

Searchable as RT128250$

@p5pRT
Copy link
Author

p5pRT commented May 26, 2016

From @cpansprout

$ perl -ne 'print if s/^=head(.)/" "x$1/e' pod/perlref.pod
  NAME
  NOTE
  DESCRIPTION
  Making References
  Using References
  Circular References
  Symbolic references
  Not-so-symbolic references
  Pseudo-hashes​: Using an array as a hash
  Function Templates
  WARNING
  Postfix Dereference Syntax
  Postfix Reference Slicing
  Assigning to References
  SEE ALSO

Most of the documentation is under the DESCRIPTION section, which makes sense. The postfix dereference syntax was added after the warning, as a top-level section, and then I blithely added the section on assigning to references after it.

The WARNING is about using references as hash keys, which may not do what you want.

Should that perhaps be made a subsection of DESCRIPTION, or should we move it to the end of the documentation, where it used to be?

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented May 27, 2016

From @jkeenan

On Thu May 26 13​:45​:51 2016, sprout wrote​:

$ perl -ne 'print if s/^=head(.)/" "x$1/e' pod/perlref.pod
NAME
NOTE
DESCRIPTION
Making References
Using References
Circular References
Symbolic references
Not-so-symbolic references
Pseudo-hashes​: Using an array as a hash
Function Templates
WARNING
Postfix Dereference Syntax
Postfix Reference Slicing
Assigning to References
SEE ALSO

Most of the documentation is under the DESCRIPTION section, which
makes sense. The postfix dereference syntax was added after the
warning, as a top-level section, and then I blithely added the section
on assigning to references after it.

The WARNING is about using references as hash keys, which may not do
what you want.

Should that perhaps be made a subsection of DESCRIPTION, or should we
move it to the end of the documentation, where it used to be?

I am attaching a patch which is a slightly more than bare-bones implementation of your suggestion. Please review.

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented May 27, 2016

From @jkeenan

0001-Place-discussion-of-postfix-under-DESCRIPTION.patch
From b51070a60425588cbe1deb86b2cfe2603bc6cff1 Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Thu, 26 May 2016 20:29:14 -0400
Subject: [PATCH] Place discussion of postfix under DESCRIPTION.

Make subheadings more consistent.  Say what the WARNING is about.

For:  RT #128250, based on suggestions by Father Chrysostomos.
---
 pod/perlref.pod | 44 ++++++++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/pod/perlref.pod b/pod/perlref.pod
index 8959ba5..f53606e 100644
--- a/pod/perlref.pod
+++ b/pod/perlref.pod
@@ -718,27 +718,7 @@ outer() at the time outer is invoked.
 This has the interesting effect of creating a function local to another
 function, something not normally supported in Perl.
 
-=head1 WARNING
-X<reference, string context> X<reference, use as hash key>
-
-You may not (usefully) use a reference as the key to a hash.  It will be
-converted into a string:
-
-    $x{ \$a } = $a;
-
-If you try to dereference the key, it won't do a hard dereference, and
-you won't accomplish what you're attempting.  You might want to do something
-more like
-
-    $r = \@a;
-    $x{ $r } = $r;
-
-And then at least you can use the values(), which will be
-real refs, instead of the keys(), which won't.
-
-The standard Tie::RefHash module provides a convenient workaround to this.
-
-=head1 Postfix Dereference Syntax
+=head2 Postfix Dereference Syntax
 
 Beginning in v5.20.0, a postfix syntax for using references is
 available.  It behaves as described in L</Using References>, but instead
@@ -798,7 +778,7 @@ As with postfix array, postfix value slice dereferencing I<can> be used
 in interpolating strings (double quotes or the C<qq> operator), but only
 if the C<postderef_qq> L<feature> is enabled.
 
-=head1 Assigning to References
+=head2 Assigning to References
 
 Beginning in v5.22.0, the referencing operator can be assigned to.  It
 performs an aliasing operation, so that the variable name referenced on the
@@ -909,6 +889,26 @@ will only be visible within that inner sub, and will not affect the outer
 subroutine where the variables are declared.  This bizarre behavior is
 subject to change.
 
+=head1 WARNING: Don't use references as hash keys
+X<reference, string context> X<reference, use as hash key>
+
+You may not (usefully) use a reference as the key to a hash.  It will be
+converted into a string:
+
+    $x{ \$a } = $a;
+
+If you try to dereference the key, it won't do a hard dereference, and
+you won't accomplish what you're attempting.  You might want to do something
+more like
+
+    $r = \@a;
+    $x{ $r } = $r;
+
+And then at least you can use the values(), which will be
+real refs, instead of the keys(), which won't.
+
+The standard Tie::RefHash module provides a convenient workaround to this.
+
 =head1 SEE ALSO
 
 Besides the obvious documents, source code can be instructive.
-- 
1.9.1

@p5pRT
Copy link
Author

p5pRT commented May 27, 2016

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

@p5pRT
Copy link
Author

p5pRT commented Dec 27, 2016

From @jkeenan

On Fri, 27 May 2016 00​:36​:32 GMT, jkeenan wrote​:

On Thu May 26 13​:45​:51 2016, sprout wrote​:

$ perl -ne 'print if s/^=head(.)/" "x$1/e' pod/perlref.pod
NAME
NOTE
DESCRIPTION
Making References
Using References
Circular References
Symbolic references
Not-so-symbolic references
Pseudo-hashes​: Using an array as a hash
Function Templates
WARNING
Postfix Dereference Syntax
Postfix Reference Slicing
Assigning to References
SEE ALSO

Most of the documentation is under the DESCRIPTION section, which
makes sense. The postfix dereference syntax was added after the
warning, as a top-level section, and then I blithely added the
section
on assigning to references after it.

The WARNING is about using references as hash keys, which may not do
what you want.

Should that perhaps be made a subsection of DESCRIPTION, or should we
move it to the end of the documentation, where it used to be?

I am attaching a patch which is a slightly more than bare-bones
implementation of your suggestion. Please review.

Thank you very much.

I have rebased my patch on blead (see attachment). Is it okay to apply?

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Dec 27, 2016

From @jkeenan

0001-Place-discussion-of-postfix-under-DESCRIPTION.patch
From 7e98726e9f967e568d6a1541beb7d81bd9aea6a1 Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Thu, 26 May 2016 20:29:14 -0400
Subject: [PATCH] Place discussion of postfix under DESCRIPTION.

Make subheadings more consistent.  Say what the WARNING is about.

For:  RT #128250, based on suggestions by Father Chrysostomos.
---
 pod/perlref.pod | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pod/perlref.pod b/pod/perlref.pod
index dfbb52c..fa9e033 100644
--- a/pod/perlref.pod
+++ b/pod/perlref.pod
@@ -718,7 +718,7 @@ outer() at the time outer is invoked.
 This has the interesting effect of creating a function local to another
 function, something not normally supported in Perl.
 
-=head1 WARNING
+=head1 WARNING: Don't use references as hash keys
 X<reference, string context> X<reference, use as hash key>
 
 You may not (usefully) use a reference as the key to a hash.  It will be
@@ -738,7 +738,7 @@ real refs, instead of the keys(), which won't.
 
 The standard Tie::RefHash module provides a convenient workaround to this.
 
-=head1 Postfix Dereference Syntax
+=head2 Postfix Dereference Syntax
 
 Beginning in v5.20.0, a postfix syntax for using references is
 available.  It behaves as described in L</Using References>, but instead
@@ -798,7 +798,7 @@ As with postfix array, postfix value slice dereferencing I<can> be used
 in interpolating strings (double quotes or the C<qq> operator), but only
 if the C<postderef_qq> L<feature> is enabled.
 
-=head1 Assigning to References
+=head2 Assigning to References
 
 Beginning in v5.22.0, the referencing operator can be assigned to.  It
 performs an aliasing operation, so that the variable name referenced on the
-- 
2.7.4

@p5pRT
Copy link
Author

p5pRT commented Jan 3, 2017

From @jkeenan

On Tue, 27 Dec 2016 02​:06​:53 GMT, jkeenan wrote​:

On Fri, 27 May 2016 00​:36​:32 GMT, jkeenan wrote​:

On Thu May 26 13​:45​:51 2016, sprout wrote​:

$ perl -ne 'print if s/^=head(.)/" "x$1/e' pod/perlref.pod
NAME
NOTE
DESCRIPTION
Making References
Using References
Circular References
Symbolic references
Not-so-symbolic references
Pseudo-hashes​: Using an array as a hash
Function Templates
WARNING
Postfix Dereference Syntax
Postfix Reference Slicing
Assigning to References
SEE ALSO

Most of the documentation is under the DESCRIPTION section, which
makes sense. The postfix dereference syntax was added after the
warning, as a top-level section, and then I blithely added the
section
on assigning to references after it.

The WARNING is about using references as hash keys, which may not do
what you want.

Should that perhaps be made a subsection of DESCRIPTION, or should we
move it to the end of the documentation, where it used to be?

I am attaching a patch which is a slightly more than bare-bones
implementation of your suggestion. Please review.

Thank you very much.

I have rebased my patch on blead (see attachment). Is it okay to apply?

Pushed to blead in commit f0d9913. Marking ticket Resolved.

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT p5pRT closed this as completed Jan 3, 2017
@p5pRT
Copy link
Author

p5pRT commented Jan 3, 2017

@jkeenan - Status changed from 'open' to 'resolved'

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

No branches or pull requests

1 participant