Edit D:\app\Administrator\product\11.2.0\dbhome_1\perl\html\lib\Class\ISA.html
<?xml version="1.0" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Class::ISA -- report the search path for a class's ISA tree</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rev="made" href="mailto:" /> </head> <body style="background-color: white"> <table border="0" width="100%" cellspacing="0" cellpadding="3"> <tr><td class="block" style="background-color: #cccccc" valign="middle"> <big><strong><span class="block"> Class::ISA -- report the search path for a class's ISA tree</span></strong></big> </td></tr> </table> <!-- INDEX BEGIN --> <div name="index"> <p><a name="__index__"></a></p> <ul> <li><a href="#name">NAME</a></li> <li><a href="#synopsis">SYNOPSIS</a></li> <li><a href="#description">DESCRIPTION</a></li> <li><a href="#functions">FUNCTIONS</a></li> <li><a href="#cautionary_notes">CAUTIONARY NOTES</a></li> <li><a href="#copyright">COPYRIGHT</a></li> <li><a href="#author">AUTHOR</a></li> </ul> <hr name="index" /> </div> <!-- INDEX END --> <p> </p> <h1><a name="name">NAME</a></h1> <p>Class::ISA -- report the search path for a class's ISA tree</p> <p> </p> <hr /> <h1><a name="synopsis">SYNOPSIS</a></h1> <pre> # Suppose you go: use Food::Fishstick, 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:</pre> <pre> @Food::Fishstick::ISA = qw(Food::Fish Life::Fungus Chemicals); @Food::Fish::ISA = qw(Food); @Food::ISA = qw(Matter); @Life::Fungus::ISA = qw(Life); @Chemicals::ISA = qw(Matter); @Life::ISA = qw(Matter); @Matter::ISA = qw();</pre> <pre> use Class::ISA; print "Food::Fishstick path is:\n ", join(", ", Class::ISA::super_path('Food::Fishstick')), "\n";</pre> <p>That prints:</p> <pre> Food::Fishstick path is: Food::Fish, Food, Matter, Life::Fungus, Life, Chemicals</pre> <p> </p> <hr /> <h1><a name="description">DESCRIPTION</a></h1> <p>Suppose you have a class (like Food::Fish::Fishstick) that is derived, via its @ISA, from one or more superclasses (as Food::Fish::Fishstick is from Food::Fish, Life::Fungus, and Chemicals), and some of those superclasses may themselves each be derived, via its @ISA, from one or more superclasses (as above).</p> <p>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, then Food, then Matter, then Life::Fungus, then Life, then Chemicals.</p> <p>This library, Class::ISA, provides functions that return that list -- the list (in order) of names of classes Perl would search to find a method, with no duplicates.</p> <p> </p> <hr /> <h1><a name="functions">FUNCTIONS</a></h1> <dl> <dt><strong><a name="super_path" class="item">the function Class::ISA::super_path($CLASS)</a></strong> <dd> <p>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.</p> </dd> </li> <dt><strong><a name="self_and_super_path" class="item">the function Class::ISA::self_and_super_path($CLASS)</a></strong> <dd> <p>Just like <a href="#super_path"><code>super_path</code></a>, except that $CLASS is included as the first element.</p> </dd> </li> <dt><strong><a name="self_and_super_versions" class="item">the function Class::ISA::self_and_super_versions($CLASS)</a></strong> <dd> <p>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).</p> </dd> <dd> <p>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.</p> </dd> </li> </dl> <p> </p> <hr /> <h1><a name="cautionary_notes">CAUTIONARY NOTES</a></h1> <p>* Class::ISA doesn't export anything. You have to address the functions with a "Class::ISA::" on the front.</p> <p>* Contrary to its name, Class::ISA isn't a class; it's just a package. Strange, isn't it?</p> <p>* Say you have a loop in the ISA tree of the class you're calling one of the Class::ISA 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 effectively ignore this cyclicity; the Class::ISA algorithm is "never go down the same path twice", and cyclicities are just a special case of that.</p> <p>* The Class::ISA 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.</p> <p>* 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 functions to be put to, but if it matters to you, then instead of this:</p> <pre> @supers = Class::Tree::super_path($class);</pre> <p>do this:</p> <pre> @supers = (Class::Tree::super_path($class), 'UNIVERSAL');</pre> <p>And don't say no-one ever told ya!</p> <p>* When you call them, the Class::ISA 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!</p> <p> </p> <hr /> <h1><a name="copyright">COPYRIGHT</a></h1> <p>Copyright (c) 1999, 2000 Sean M. Burke. All rights reserved.</p> <p>This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.</p> <p> </p> <hr /> <h1><a name="author">AUTHOR</a></h1> <p>Sean M. Burke <code>sburke@cpan.org</code></p> <table border="0" width="100%" cellspacing="0" cellpadding="3"> <tr><td class="block" style="background-color: #cccccc" valign="middle"> <big><strong><span class="block"> Class::ISA -- report the search path for a class's ISA tree</span></strong></big> </td></tr> </table> </body> </html>
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de