-
Notifications
You must be signed in to change notification settings - Fork 555
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
__PACKAGE__ does not work as a hash key #13074
Comments
From @jimavThis is a bug report for perl from james_avera@yahoo.com, #!/usr/bin/perl sub show($) { defined($_[0]) ? ("'".$_[0]."'") : "undef" } my %table = ( main => "the-value" ); warn "__PACKAGE__ = ",show(__PACKAGE__),"\n"; die "bug" unless show($table{__PACKAGE__}) eq show($table{main}); Flags: Site configuration information for perl 5.14.2: Configured by Debian Project at Mon Apr 15 15:34:46 UTC 2013. Summary of my perl5 (revision 5 version 14 subversion 2) configuration: Locally applied patches: @INC for perl 5.14.2: Environment for perl 5.14.2: |
From @cpansproutOn Sat Jun 29 23:53:13 2013, jimav wrote:
That’s because hash keys auto-quote. You have to write The same applies, e.g., to $table{time}, which will use "time" rather That’s a feature. :-) -- Father Chrysostomos |
The RT System itself - Status changed from 'new' to 'open' |
From @jkeenanOn 6/30/13 2:53 AM, Jim Avera wrote:
This limitation has been documented in 'perlmod' since 1997: ##### Is there any compelling reason why we should alter this long-standing Thank you very much. |
From @jimavOn 06/30/2013 05:06 AM, James E Keenan via RT wrote:
At this point in Perl's history not much is really compelling, so I But still, perldata says __PACKAGE__ etc. are "special literals" which I found this the hard way (i.e. as a silent bug) when $hash{__PACKAGE__} -Jim |
From @maukeOn 02.07.2013 00:42, Jim Avera wrote:
Wrong part of the documentation. The above only means you can't say
As Father Chrysostomos explained, hash keys always autoquote -- |
From @b2gillsOn Mon, Jul 1, 2013 at 10:46 PM, Lukas Mai <plokinom@gmail.com> wrote:
If you need the special literal there are a few easy ways to do it perl -E'%h=(main=>"Hello World"); say $h{+ __PACKAGE__ }' basically anything that tells perl (the compiler) that you want on 5.16 or later you can also pretend it is a subroutine |
From @jkeenanOn Mon Jul 01 22:44:37 2013, brad wrote:
So, do we have a bug here? A feature? Something that needs better documentation? Thank you very much. |
From @b2gillsOn Tue, Jul 2, 2013 at 5:52 PM, James E Keenan via RT
This is an intended feature, not a bug. As for documentation, we always could use improvement If we added a bit about how to use the special literal Maybe we could add it to perldata in the subscripts section. I don't think it's worth holding this ticket open for that though. --- There was a bit of discussion about allowing this to do __PACKAGE__::SubPackage but that is not the topic of this bug report. |
From @jimavOn 07/02/2013 03:52 PM, James E Keenan via RT wrote:
The special __(PACKAGE|FILE|LINE)__ symbols are well-documented and But I'm not familiar with perl internals, so doing so might be I think those who would do the work are the only ones qualified to say |
From @ikegamiOn Tue, Jul 2, 2013 at 9:09 PM, Jim Avera <james_avera@yahoo.com> wrote:
You could say exactly the same for `split`, `uc`, etc And that's why it would make things worse. |
From @rjbsWe're not changing this. -- |
From [Unknown Contact. See original ticket]We're not changing this. -- |
@rjbs - Status changed from 'open' to 'rejected' |
From @jimavOn 07/03/2013 04:08 AM, Eric Brine wrote:
Ok, I see your point. Death, taxes, and ambiguous programming languages. |
Migrated from rt.perl.org#118701 (status was 'rejected')
Searchable as RT118701$
The text was updated successfully, but these errors were encountered: