Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: getting a list of all subclasses of base class x

by moritz (Cardinal)
on Jul 08, 2008 at 16:35 UTC ( [id://696254]=note: print w/replies, xml ) Need Help??


in reply to getting a list of all subclasses of base class x

You can try to walk the symbol tables (described in perlmod) and check @ISA in each package.

But in general it's a sign of a bad design if you have to know about subclasses, because you do subclassing specifically to enable a functionality that wasn't intended when writing the super class.

Replies are listed 'Best First'.
Re^2: getting a list of all subclasses of base class x
by hexcoder (Curate) on Jul 08, 2008 at 19:24 UTC
    I want to process the token stream generated from PPI.
    So I want to enumerate and store each of its token types.

    I agree with your design objection, so I asked Adam Kennedy, if there is a method to list all such token classes in PPI. I will see what he suggests...

      http://search.cpan.org/src/ADAMK/PPI-1.203/lib/PPI/Token.pm
      #!/usr/bin/perl -- use strict; use warnings; use PPI::Token; print $_,$/ for map { s/\.pm//; s~/~::~g; $_; } sort grep /Token\W/, keys %INC; __END__ PPI::Token PPI::Token::ArrayIndex PPI::Token::Attribute PPI::Token::Cast PPI::Token::Comment PPI::Token::DashedWord PPI::Token::Data PPI::Token::End PPI::Token::HereDoc PPI::Token::Label PPI::Token::Magic PPI::Token::Number PPI::Token::Number::Binary PPI::Token::Number::Exp PPI::Token::Number::Float PPI::Token::Number::Hex PPI::Token::Number::Octal PPI::Token::Number::Version PPI::Token::Operator PPI::Token::Pod PPI::Token::Prototype PPI::Token::Quote PPI::Token::Quote::Double PPI::Token::Quote::Interpolate PPI::Token::Quote::Literal PPI::Token::Quote::Single PPI::Token::QuoteLike PPI::Token::QuoteLike::Backtick PPI::Token::QuoteLike::Command PPI::Token::QuoteLike::Readline PPI::Token::QuoteLike::Regexp PPI::Token::QuoteLike::Words PPI::Token::Regexp PPI::Token::Regexp::Match PPI::Token::Regexp::Substitute PPI::Token::Regexp::Transliterate PPI::Token::Separator PPI::Token::Structure PPI::Token::Symbol PPI::Token::Unknown PPI::Token::Whitespace PPI::Token::Word PPI::Token::_QuoteEngine PPI::Token::_QuoteEngine::Full PPI::Token::_QuoteEngine::Simple
      I want to process the token stream generated from PPI. So I want to enumerate and store each of its token types.

      Maybe you can enumerate them lazily as you encounter them? Something along these lines:

      use Memoize qw(memoize); memoize qw(number_for_class); sub number_for_class { state $i; return ++$i };

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-07-24 22:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    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.