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

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

by NERDVANA (Curate)
on Oct 08, 2021 at 06:17 UTC ( [id://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 studying the Monastery: (3)
As of 2024-07-19 22:13 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.