Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Is there a Perl API (XS) for ->can ?

by NERDVANA (Monk)
on Oct 08, 2021 at 06:17 UTC ( #11137334=perlquestion: print w/replies, xml ) Need Help??

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

Hi, in one of my XS modules I want to do the equivalent of PKG->can($method). It feels like this would be in the perl api, but keyword searching for 'can' is somewhat futile. Is there any way to run this operation more efficiently than literally building a call to method 'can'?

Replies are listed 'Best First'.
Re: Is there a Perl API (XS) for ->can ?
by Anonymous Monk on Oct 08, 2021 at 09:06 UTC
      Thanks! gv_fetchmeth was what I was looking for.
Re: Is there a Perl API (XS) for ->can ?
by LanX (Sage) on Oct 08, 2021 at 08:39 UTC
    FWIW: My idea was that a direct call is more efficient.

    Hence the XS equivalent to

    $sub = UNIVERSAL::can($obj, "print");

    But UNIVERSAL says

    > # but never do this!

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

    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2021-10-25 14:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (89 votes). Check out past polls.

    Notices?