SPUG: oddity (bug?) with isa()
Showell30 at aol.com
Showell30 at aol.com
Tue Mar 20 10:49:11 CST 2001
In a message dated 3/19/01 11:38:59 PM Pacific Standard Time,
largest at largest.org writes:
> Riley and I have been puzzling over some seemingly odd isa() behavior.
> Our understanding was that when you call
> Perl would look in @Widget::ISA for 'Thingie'--if it's there isa() returns
> true, else it returns false. It appears, however, that something else is
> also going on. One thought is that Perl is also checking to see if
> there's a 'Thingie' symbol table.
> Consider the following code, a calling script and 2 versions of Widget.pm.
> The only difference in the versions of the module is the 'package Thingy;'
> line in the 2nd version.
> use'ing version 1, the calling script outputs "Nope, not a Thingy\n".
> use'ing version 2, the calling script outputs "As I suspected, it's a
The isa function does a lot more than look for "Thingy" in @Widget::ISA,
because it has to look for grandparent classes. When isa searches the
inheritance tree for Thingy, presumably it verifies that ISA'd packages are,
in fact, packages, and perl does warns you if they're not (as expected), and
isa does return false if they're not (not expected??). Damian's book points
out some interesting facts about isa. For example, the isa function is hard
coded into the Perl executable, and for greater speed, it memorizes its
P.S. I misread your original post a bit before sending my previous reply. I
guess you had already figured out that the nonexistence of package Thingy
caused isa to act unexpectedly. I hope my elaboration here sheds more light.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
More information about the spug-list