Paul wrote:
> My question is: how do I write inheritable code?
> Currently, the problem plaguing me is that I want the parent class's
> record-reading method to directly call the child class's record
> *parsing* method. (feel free to point and laugh, as long as you have a
> better suggestion. =o)
Someone please correct me if I am wrong:
The fact that the methods resolve to C routines does not affect
how Perl binds methods to objects, which is by looking in the object's
own package, and then looking in the packages named in its @ISA.
> I get confused as to how the inheritance system interacts with C
> scoping. My C is rusty anyway.
Inlined C functions are inserted into the current package. I doubt
that global symbols are visible between C blocks but do not know for
sure.
> How do I make sure the parent class's
> reading method calls the child class's init() method?
package parent;
use Carp;
sub init() { confess "Need to bless into a child package before init'ing"
};
> Would it be best to just leave them seperate, and then write a Perl
> wrapper method that bundles the functionalities?
>
> Suggestions?
Maybe you could start by drawing a picture of what data needs to be
visible to what methods. You can have perl pass any kinds of records
around as scalar strings.