# phpman > man > Class::ISA

## NAME
    [Class::ISA](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3AISA/markdown) - report the search path for a class's ISA tree

## SYNOPSIS
      # Suppose you go: use [Food::Fishstick](https://www.chedong.com/phpMan.php/perldoc/Food%3A%3AFishstick/markdown), and that uses and
      # inherits from other things, which in turn use and inherit
      # from other things.  And suppose, for sake of brevity of
      # example, that their ISA tree is the same as:

      @[Food::Fishstick::ISA](https://www.chedong.com/phpMan.php/perldoc/Food%3A%3AFishstick%3A%3AISA/markdown) = qw([Food::Fish](https://www.chedong.com/phpMan.php/perldoc/Food%3A%3AFish/markdown)  [Life::Fungus](https://www.chedong.com/phpMan.php/perldoc/Life%3A%3AFungus/markdown)  Chemicals);
      @[Food::Fish::ISA](https://www.chedong.com/phpMan.php/perldoc/Food%3A%3AFish%3A%3AISA/markdown) = qw(Food);
      @[Food::ISA](https://www.chedong.com/phpMan.php/perldoc/Food%3A%3AISA/markdown) = qw(Matter);
      @[Life::Fungus::ISA](https://www.chedong.com/phpMan.php/perldoc/Life%3A%3AFungus%3A%3AISA/markdown) = qw(Life);
      @[Chemicals::ISA](https://www.chedong.com/phpMan.php/perldoc/Chemicals%3A%3AISA/markdown) = qw(Matter);
      @[Life::ISA](https://www.chedong.com/phpMan.php/perldoc/Life%3A%3AISA/markdown) = qw(Matter);
      @[Matter::ISA](https://www.chedong.com/phpMan.php/perldoc/Matter%3A%3AISA/markdown) = qw();

      use [Class::ISA](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3AISA/markdown);
      print "[Food::Fishstick](https://www.chedong.com/phpMan.php/perldoc/Food%3A%3AFishstick/markdown) path is:\n ",
            join(", ", [Class::ISA::super_path](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3AISA%3A%3Asuperpath/markdown)('[Food::Fishstick](https://www.chedong.com/phpMan.php/perldoc/Food%3A%3AFishstick/markdown)')),
            "\n";

    That prints:

      [Food::Fishstick](https://www.chedong.com/phpMan.php/perldoc/Food%3A%3AFishstick/markdown) path is:
       [Food::Fish](https://www.chedong.com/phpMan.php/perldoc/Food%3A%3AFish/markdown), Food, Matter, [Life::Fungus](https://www.chedong.com/phpMan.php/perldoc/Life%3A%3AFungus/markdown), Life, Chemicals

## DESCRIPTION
    Suppose you have a class (like [Food::Fish::Fishstick](https://www.chedong.com/phpMan.php/perldoc/Food%3A%3AFish%3A%3AFishstick/markdown)) that is derived, via its @ISA, from one or
    more superclasses (as [Food::Fish::Fishstick](https://www.chedong.com/phpMan.php/perldoc/Food%3A%3AFish%3A%3AFishstick/markdown) is from [Food::Fish](https://www.chedong.com/phpMan.php/perldoc/Food%3A%3AFish/markdown), [Life::Fungus](https://www.chedong.com/phpMan.php/perldoc/Life%3A%3AFungus/markdown), and Chemicals),
    and some of those superclasses may themselves each be derived, via its @ISA, from one or more
    superclasses (as above).

    When, then, you call a method in that class ($fishstick->calories), Perl first searches there
    for that method, but if it's not there, it goes searching in its superclasses, and so on, in a
    depth-first (or maybe "height-first" is the word) search. In the above example, it'd first look
    in [Food::Fish](https://www.chedong.com/phpMan.php/perldoc/Food%3A%3AFish/markdown), then Food, then Matter, then [Life::Fungus](https://www.chedong.com/phpMan.php/perldoc/Life%3A%3AFungus/markdown), then Life, then Chemicals.

    This library, [Class::ISA](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3AISA/markdown), provides functions that return that list -- the list (in order) of
    names of classes Perl would search to find a method, with no duplicates.

## FUNCTIONS
    the function [Class::ISA::super_path](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3AISA%3A%3Asuperpath/markdown)($CLASS)
        This returns the ordered list of names of classes that Perl would search thru in order to
        find a method, with no duplicates in the list. $CLASS is not included in the list. UNIVERSAL
        is not included -- if you need to consider it, add it to the end.

    the function [Class::ISA::self_and_super_path](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3AISA%3A%3Aselfandsuperpath/markdown)($CLASS)
        Just like "super_path", except that $CLASS is included as the first element.

    the function [Class::ISA::self_and_super_versions](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3AISA%3A%3Aselfandsuperversions/markdown)($CLASS)
        This returns a hash whose keys are $CLASS and its (super-)superclasses, and whose values are
        the contents of each class's $VERSION (or undef, for classes with no $VERSION).

        The code for self_and_super_versions is meant to serve as an example for precisely the kind
        of tasks I anticipate that self_and_super_path and super_path will be used for. You are
        strongly advised to read the source for self_and_super_versions, and the comments there.

## CAUTIONARY NOTES
    * [Class::ISA](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3AISA/markdown) doesn't export anything. You have to address the functions with a "[Class::ISA](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3AISA/markdown)::" on
    the front.

    * Contrary to its name, [Class::ISA](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3AISA/markdown) isn't a class; it's just a package. Strange, isn't it?

    * Say you have a loop in the ISA tree of the class you're calling one of the [Class::ISA](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3AISA/markdown)
    functions on: say that Food inherits from Matter, but Matter inherits from Food (for sake of
    argument). If Perl, while searching for a method, actually discovers this cyclicity, it will
    throw a fatal error. The functions in [Class::ISA](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3AISA/markdown) effectively ignore this cyclicity; the
    [Class::ISA](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3AISA/markdown) algorithm is "never go down the same path twice", and cyclicities are just a special
    case of that.

    * The [Class::ISA](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3AISA/markdown) functions just look at @ISAs. But theoretically, I suppose, AUTOLOADs could
    bypass Perl's ISA-based search mechanism and do whatever they please. That would be bad
    behavior, tho; and I try not to think about that.

    * If Perl can't find a method anywhere in the ISA tree, it then looks in the magical class
    UNIVERSAL. This is rarely relevant to the tasks that I expect [Class::ISA](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3AISA/markdown) functions to be put to,
    but if it matters to you, then instead of this:

      @supers = [Class::Tree::super_path](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3ATree%3A%3Asuperpath/markdown)($class);

    do this:

      @supers = ([Class::Tree::super_path](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3ATree%3A%3Asuperpath/markdown)($class), 'UNIVERSAL');

    And don't say no-one ever told ya!

    * When you call them, the [Class::ISA](https://www.chedong.com/phpMan.php/perldoc/Class%3A%3AISA/markdown) functions look at @ISAs anew -- that is, there is no
    memoization, and so if ISAs change during runtime, you get the current ISA tree's path, not
    anything memoized. However, changing ISAs at runtime is probably a sign that you're out of your
    mind!

## COPYRIGHT AND LICENSE
    Copyright (c) 1999-2009 Sean M. Burke. All rights reserved.

    This library is free software; you can redistribute it and/or modify it under the same terms as
    Perl itself.

## AUTHOR
    Sean M. Burke "<sburke@cpan.org>"

## MAINTAINER
    Maintained by Steffen Mueller "<smueller@cpan.org>".

