Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

isa for ref?

by LanX (Saint)
on Jun 20, 2020 at 22:09 UTC ( [id://11118291]=perlquestion: print w/replies, xml ) Need Help??

LanX has asked for the wisdom of the Perl Monks concerning the following question:

saw this in Algorithm::Loops

DB<71> $code = sub {} DB<72> p ref $code CODE DB<73> *isa = \&UNIVERSAL::isa # import DB<74> p isa($code,"CODE") # ??? 1 DB<75>

Where is this behavior of isa() documented and why would one want to do this?

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re: isa for ref?
by tobyink (Canon) on Jun 20, 2020 at 22:14 UTC

    It's documented towards the end of UNIVERSAL. And you don't want to do it. isa is a method, not a function.

      isa is a method, not a function.
      SCNR: Unless you're running Perl 5.32, where isa is an infix operator.
Re: isa for ref?
by choroba (Cardinal) on Jun 20, 2020 at 22:14 UTC
    > why would one want to do this

    Maybe because of

    my $ref = bless sub {}, 'MyClass'; say ref($ref) eq 'CODE' ? 1 : 0; say UNIVERSAL::isa($ref, 'CODE') ? 1 : 0;
    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
      yeah, but that's why we have Scalar::Util::reftype() now

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11118291]
Approved by kcott
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-04-19 04:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found