Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
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 ( #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
Node Status?
node history
Node Type: note [id://697723]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2019-12-06 20:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (159 votes). Check out past polls.

    Notices?