>>>>> "DN" == Damien Neil <[EMAIL PROTECTED]> writes:
DN> For example:
DN> package Dog;
DN> sub bark { } # Index = 0.
DN> sub bite { } # Index = 1.
DN> The Dog vtable now looks like this:
DN> 0 Dog::bark
DN> 1 Dog::bite
DN> Define a couple of subclasses of Dog:
DN> package Corgi;
DN> sub bark { } # Overrides base class definition; index = 0.
DN> sub sleep { } # New sub; index = 2.
DN> package Mutt;
DN> sub bark { } # Overrides base class definition; index = 0.
DN> sub read_mail { } # New sub; index = 2.
DN> sub sleep { } # New sub; index = 3.
DN> The Corgi vtable is:
DN> 0 Corgi::bark
DN> 1 Dog::bite
DN> 2 Corgi::sleep
DN> The Mutt vtable is:
DN> 0 Mutt::bark
DN> 1 Dog::bite
DN> 2 Mutt::read_mail
DN> 3 Mutt::sleep
this assumes that the modules are loaded in the correct order. it seems
that a subclass would have to know the vtable of the parent before it
could slot its methods.
and how does this work with our good friend AUTOLOAD? you can't tell
that a parent actually has a slot until you call AUTOLOAD.
maybe we should have an %AUTOLOAD hash which is given all the method
names you may create? since many AUTOLOADS are for accessors, and you
know those names in advance it wouldn't be hard to enforce.
uri
--
Uri Guttman --------- [EMAIL PROTECTED] ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com