-
Notifications
You must be signed in to change notification settings - Fork 550
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
ref function returns 'Regexp', not 'REGEXP' for qr// #16801
Comments
From @djeriusCreated by @djeriusThe documentation for the ref() function indicates that it % perl -le 'print ref( qr// )' As far as I can recall (and verified with Perl 5.8.8) it has Perl Info
|
From @mfontaniOn Thu, 03 Jan 2019 09:15:54 -0800, djerius wrote:
See attached patch, which also references the commit Hope this helps, |
From @mfontani0001-fix-perldoc-f-ref-return-value-for-Regexp.patchFrom a9acc5184fbee966b58dc71084360bfdfafc1bff Mon Sep 17 00:00:00 2001
From: Marco Fontani <MFONTANI@cpan.org>
Date: Thu, 3 Jan 2019 18:24:59 +0100
Subject: [PATCH] fix "perldoc -f ref" return value for Regexp
... which was (mistakenly?) switched from Regexp to REGEXP in commit
f3c710fe342032112ac92fc893f5ef050b4f7024
For RT #133751
---
pod/perlfunc.pod | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 664e2a3e0c..a6273bf183 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -6378,7 +6378,7 @@ a scalar, then the return value will be one of the strings C<ARRAY>,
C<HASH>, C<CODE>, C<FORMAT>, or C<IO>, indicating only which kind of
object it is. If the unblessed referent is a scalar, then the return
value will be one of the strings C<SCALAR>, C<VSTRING>, C<REF>, C<GLOB>,
-C<LVALUE>, or C<REGEXP>, depending on the kind of value the scalar
+C<LVALUE>, or C<Regexp>, depending on the kind of value the scalar
currently has. Beware that these built-in type names can also be used as
class names, so C<ref> returning one of these names doesn't unambiguously
indicate that the referent is of the kind to which the name refers.
--
2.20.1
|
The RT System itself - Status changed from 'new' to 'open' |
From @jkeenanOn Thu, 03 Jan 2019 17:15:54 GMT, djerius wrote:
Yes. It appears that it's Scalar::Util::reftype() which returns the all-upper-case string. ##### List: How should we handle this? (Simplest might be to just change the documentation in pod/perlfunc.pod around line 6381.) Thank you very much. -- |
From gm@qwurx.deFrom the keyboard of James E Keenan via RT [03.01.19,09:36]:
I think it should return REGEXP, since that is consistent with the
0--gg- -- |
From @LeontOn Thu, Jan 3, 2019 at 9:37 PM shmem <gm@qwurx.de> wrote:
Unlike the examples you mention, a regexp is a blessed reference, perl -E 'sub Regexp::foo { say "HERE" }; qr//->foo Leon |
From gm@qwurx.deFrom the keyboard of Leon Timmermans [03.01.19,22:18]:
Ah, ok. Then probably Regexp is right, since it is, hm, a package name
Well, DESTROY is defined, although it doesn't do anything ;) </nitpick>
0--gg- -- |
From @iabynOn Thu, Jan 03, 2019 at 10:39:51PM +0100, shmem wrote:
I think the docs should say (as before): If the unblessed referent is a scalar, then the return But append: But note that C<qr//> scalars are created already blessed, so -- |
From Eirik-Berg.Hanssen@allverden.noOn Fri, Jan 4, 2019 at 12:47 AM Dave Mitchell <davem@iabyn.com> wrote:
Ah, indeed: $ perl -E 'use overload; say overload::StrVal(qr//)'
A good note, if you ask me. Eirik |
From @cpansproutOn Thu, 03 Jan 2019 15:46:45 -0800, davem wrote:
Interesting: $ perl -le '$x = qr//; I did not realize you could get that with pure Perl. -- Father Chrysostomos |
From @demerphqOn Fri, 4 Jan 2019 at 00:46, Dave Mitchell <davem@iabyn.com> wrote:
FWIW, this is a historical issue. Way back in time before Nicholas
Would it be worth mentioning Scalar::Util::reftype() here as well? Yves -- |
From @xsawyerxOn 1/4/19 6:04 PM, demerphq wrote:
+1
+1 |
From @tonycozOn Sat, 05 Jan 2019 13:46:31 -0800, xsawyerx@gmail.com wrote:
See the attached patch.
Immediately following this paragraph: The ambiguity between built-in type names and class names significantly I don't think it needs another mention. Tony |
From @tonycoz0001-perl-133751-qr-is-already-blessed.patchFrom 818ed1fc594998f6295c8bf03ccc5c7c8e27592a Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Wed, 16 Jan 2019 09:42:16 +1100
Subject: (perl #133751) qr// is already blessed
---
pod/perlfunc.pod | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 7c37a0e775..973a2612d7 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -6379,7 +6379,9 @@ C<HASH>, C<CODE>, C<FORMAT>, or C<IO>, indicating only which kind of
object it is. If the unblessed referent is a scalar, then the return
value will be one of the strings C<SCALAR>, C<VSTRING>, C<REF>, C<GLOB>,
C<LVALUE>, or C<REGEXP>, depending on the kind of value the scalar
-currently has. Beware that these built-in type names can also be used as
+currently has. But note that C<qr//> scalars are created already
+blessed, so C<ref qr/.../> will likely return C<Regexp>. Beware that
+these built-in type names can also be used as
class names, so C<ref> returning one of these names doesn't unambiguously
indicate that the referent is of the kind to which the name refers.
--
2.11.0
|
From @tonycozOn Tue, 15 Jan 2019 14:45:47 -0800, tonyc wrote:
Applied as 4829a1e. 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#133751 (status was 'resolved')
Searchable as RT133751$
The text was updated successfully, but these errors were encountered: