-
Notifications
You must be signed in to change notification settings - Fork 560
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
Confusingly, perlref calls a hash in the examples %array #16782
Comments
From choroba@matfyz.czCreated by @chorobaThe subject says it all. $array{ aaa }{ bbb }{ ccc } is confusing, Patch attached. Perl Info
|
From choroba@matfyz.cz0001-Call-a-hash-hash-in-the-documentation.patchFrom 4f095002c0ee207d432500ebc63edc924f1d88b5 Mon Sep 17 00:00:00 2001
From: "E. Choroba" <choroba@cpan.org>
Date: Wed, 5 Dec 2018 23:49:57 +0100
Subject: [PATCH] Call a hash %hash in the documentation
Previously, %array was used which was confusing.
---
pod/perlref.pod | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/pod/perlref.pod b/pod/perlref.pod
index cf3692212d..4982b65c8d 100644
--- a/pod/perlref.pod
+++ b/pod/perlref.pod
@@ -603,23 +603,23 @@ Similarly, because of all the subscripting that is done using single words,
the same rule applies to any bareword that is used for subscripting a hash.
So now, instead of writing
- $array{ "aaa" }{ "bbb" }{ "ccc" }
+ $hash{ "aaa" }{ "bbb" }{ "ccc" }
you can write just
- $array{ aaa }{ bbb }{ ccc }
+ $hash{ aaa }{ bbb }{ ccc }
and not worry about whether the subscripts are reserved words. In the
rare event that you do wish to do something like
- $array{ shift }
+ $hash{ shift }
you can force interpretation as a reserved word by adding anything that
makes it more than a bareword:
- $array{ shift() }
- $array{ +shift }
- $array{ shift @_ }
+ $hash{ shift() }
+ $hash{ +shift }
+ $hash{ shift @_ }
The C<use warnings> pragma or the B<-w> switch will warn you if it
interprets a reserved word as a string.
--
2.13.7
|
From @jkeenanOn Wed, 05 Dec 2018 23:04:52 GMT, choroba@matfyz.cz wrote:
The code examples you are proposing to change were written by Larry Wall in commit 748a930 in March 1995. We haven't changed them in all that time ... which makes me suspect we have a reason for doing so (though I myself don't know what that reason is). Thank you very much. |
The RT System itself - Status changed from 'new' to 'open' |
From @iabynOn Wed, Dec 05, 2018 at 07:07:27PM -0800, James E Keenan via RT wrote:
I should imagine it's because until perl 5, hashes were called associative -- |
From @davidnicolOn Thu, Dec 6, 2018 at 3:57 AM Dave Mitchell <davem@iabyn.com> wrote:
That's what we called them in data structures class at university. Hash is either cannabis or corned beef and spuds, and the fact that Perl Associative arrays are called variously "maps" or "dictionaries" in the I guess I'm arguing to leave it alone, so we've got an example of calling -- |
From jjuran@gmail.comOn Dec 6, 2018, at 12:27 PM, David Nicol <davidnicol@gmail.com> wrote:
Unless you consider algorithmic complexity guarantees to be part of the interface. Also, is the hash table still an implementation detail when "hash" explicitly quotes it? That sounds like specified behavior to me. Josh |
From choroba@matfyz.czHere's the link to a confused newbie's question: https://www.perlmonks.org/?node_id=1226776 If we want to use "associative array", we should be consistent, and rename all the remaining hashes in the document (and probably other documents, too). But I find changing just these 6 lines much easier. |
From @tonycozOn Fri, 07 Dec 2018 17:00:53 -0800, choroba@matfyz.cz wrote:
I agree. Thanks, applied as f06965b. Tony |
@tonycoz - Status changed from 'open' to 'pending release' |
From @khwilliamsonThank you for filing this report. You have helped make Perl better. With the release today of Perl 5.30.0, this and 160 other issues have been Perl 5.30.0 may be downloaded via: If you find that the problem persists, feel free to reopen this ticket. |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#133712 (status was 'resolved')
Searchable as RT133712$
The text was updated successfully, but these errors were encountered: