Phoenix.pm: Re: OOP Question

Beaves at aol.com Beaves at aol.com
Tue Feb 8 13:37:00 CST 2000


Hi, sorry, I can't make the meeting tonight. 

When your run the parser, and XML::doc (et al) springs into existence, have 
you looked at whether the parser at that point defines @XML::doc::ISA?  If 
this occurs when you run the parser, it will be overwriting any definitions 
of @XML::doc::ISA that you may have already defined, which might be screwing 
up you inheritance plan.

Have you thought about maybe adding a class the XML inherits from?  Something 
like:
    push(@XML::ISA, 'XML::DougsXML')

and then defining all the same methods but in XML::DougsXML.  This way, any 
method called that finds its way to XML and is still not found, will 
eventually be found in DougsXML by inheritance.  (of course, be leery of your 
method names in this case, so they won't be found before the lookup gets to 
your level).

Also, you said something interesting not finding the package declarations 
anywhere in the source code.  It may be done in a way you are not expecting.  
Since the XML parser does not know what elements it will later have to create 
packages for, it may be done in an indirect fashion.  It may be doing 
something like:

    my $element = shift;  # or however the parser gets the string...
    my $class = "XML::$element";
    @{"$class\::ISA"} = (XML);
    bless $somehash, $class;

Now, you can call methods like
    XML::doc->traverse;
or
    $someobject->traverse

and it will have the inheritance you would expect.

I'm not sure if this was what you were getting at with the package 
declaration stuff, but if not, then maybe someone else can use it.

Have fun at the meeting tonight!

Tim



More information about the Phoenix-pm mailing list