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

Re^2: Listing the functions of a package / methods of an object

by amir_e_a (Hermit)
on Jul 15, 2008 at 14:22 UTC ( [id://697723]=note: print w/replies, xml ) Need Help??


in reply to Re: Listing the functions of a package / methods of an object
in thread Listing the functions of a package / methods of an object

> Use Moose or another OO framework that allows easy introspection.

Hmm ... but nothing for the old-fashioned plain blessed packages?..

> Without having checked, I think your code will fail to list method in superclasses of $object

You're right :(

> And shouldn't $result be really <c>$object?

Of course it should :)

  • Comment on Re^2: Listing the functions of a package / methods of an object

Replies are listed 'Best First'.
Re^3: Listing the functions of a package / methods of an object
by karavelov (Monk) on Jul 15, 2008 at 16:28 UTC
    Class::MOP (which is the foundation of Moose) works well with the "old-fashioned" plain blessed hashref packages and has the functionality you are looking for. It is provided via Class::MOP::Class method_map.
Re^3: Listing the functions of a package / methods of an object
by moritz (Cardinal) on Jul 15, 2008 at 14:52 UTC
    Hmm ... but nothing for the old-fashioned plain blessed packages?..

    I think you can do better (for example recurse into the classes @ISA, and filter out methods beginning with an underscore (which are private by convention), DESTROY etc.), but there are conceptual limits.

    Perl doesn't have different declarations for subs and methods, so it's impossible to distinguish these two automatically.

    Maybe there are better solutions to your problem. For example the thread Runtime introspection: What good is it? discusses (among a variety of other things) possible alternatives to to introspection.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-23 12:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found