develooper Front page | perl.perl5.porters | Postings from January 2019

[perl #133751] ref function returns 'Regexp', not 'REGEXP' for qr//

From:
Tony Cook via RT
Date:
January 15, 2019 22:45
Subject:
[perl #133751] ref function returns 'Regexp', not 'REGEXP' for qr//
Message ID:
rt-4.0.24-3508-1547592347-894.133751-15-0@perl.org
On Sat, 05 Jan 2019 13:46:31 -0800, xsawyerx@gmail.com wrote:
> 
> On 1/4/19 6:04 PM, demerphq wrote:
> > On Fri, 4 Jan 2019 at 00:46, Dave Mitchell <davem@iabyn.com> wrote:
> >> I think the docs should say (as before):
> >>
> >> 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.
> >>
> >> But append:
> >>
> >> But note that C<qr//> scalars are created already blessed, so
> >> C<ref qr/.../> will likely return C<Regexp>.
> 
> 
> +1

See the attached patch.

> 
> 
> > Would it be worth mentioning Scalar::Util::reftype() here as well?
> 
> 
> +1

Immediately following this paragraph:

The ambiguity between built-in type names and class names significantly
limits the utility of C<ref>.  For unambiguous information, use
L<C<Scalar::Util::blessed()>|Scalar::Util/blessed> for information about
blessing, and L<C<Scalar::Util::reftype()>|Scalar::Util/reftype> for
information about physical types.  Use L<the C<isa> method|UNIVERSAL/C<<
$obj->isa( TYPE ) >>> for class membership tests, though one must be
sure of blessedness before attempting a method call.

I don't think it needs another mention.

Tony

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=133751



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About