Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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

by NERDVANA (Deacon)
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 (Saint) 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?

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
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2023-12-06 04:54 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (29 votes). Check out past polls.