|Do you know where your variables are?|
Object inheritance and AUTOLOADby zejames (Hermit)
|on Dec 04, 2004 at 11:45 UTC||Need Help??|
Today I encountered some issue trying to use Object inheritance and AUTOLOAD at the same time.
Let me explain : Let's say we have a Dog class, of which a Husky class inherits. AUTOLOAD is used to managed simple attributes, for exampe for setting and getting.
Now there are some attributes that should be managed by AUTOLOAD in the Dog class, and some specific attributes that should be in the Husky class. That raises the problem : AUTOLOAD is only called once, from the package the objects belongs to. There is not AUTOLOAD automatic inheritance.
Easy, will you say, let's call parent AUTOLOAD. Ok, by one must take care of the fact the scalar $AUTOLOAD is only defined in the object package.
So, to make it work, I finally wrote the code below. The idea is really simple, and I guess I may be reinventing the wheel, but anyway... Husky AUTOLOAD is as expected, but finally calls Dog's AUTOLOAD. Dog AUTOLOAD takes care of the fact that it could be called in two ways : either directly, if we have a Dog object, or from Husky AUTOLOAD. Comments are welcome...