X
xhoster
I have a lot of scripts that use a memory-hungry module, but most of them
use only a small subset of that module's features, and it should be
possible to implement that subset in a more memory efficient way.
I want to "subclass" the memory hungry module. Many of the methods, ones
which are rarely used and can't be made memory efficient, will not be
implemented in the subclass.
I could define subs in the subclass for each such method, invoking croak or
die so the call doesn't get dispatched up the @ISA list. But I want the
default to lie the other way around, methods are unimplemented unless other
specified.
I guess I could walk the superclass's symbol table, automatically defining
a croaking sub for every subroutine in that symbol table unless they are in
my "implemented" list. But that seems rather hackish. Is there a better
way to do that?
Other options would be to *not* put the superclass in @ISA, and manually
redispatch calls to the superclass when that is the proper thing to do,
with unimplemented ones getting exceptions from Perl rather than explicit
ones. Is there some pitfall in doing this?
Or I could just do a complete code-fork and have the two modules completely
unrelated other than happening to have many method names in common. This
loses improvements made to the superclass. But since any new methods would
have to be manually inspected for compatibility before adding them to the
redispatch list anyway, I am not sure this is really a meaningful problem.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
use only a small subset of that module's features, and it should be
possible to implement that subset in a more memory efficient way.
I want to "subclass" the memory hungry module. Many of the methods, ones
which are rarely used and can't be made memory efficient, will not be
implemented in the subclass.
I could define subs in the subclass for each such method, invoking croak or
die so the call doesn't get dispatched up the @ISA list. But I want the
default to lie the other way around, methods are unimplemented unless other
specified.
I guess I could walk the superclass's symbol table, automatically defining
a croaking sub for every subroutine in that symbol table unless they are in
my "implemented" list. But that seems rather hackish. Is there a better
way to do that?
Other options would be to *not* put the superclass in @ISA, and manually
redispatch calls to the superclass when that is the proper thing to do,
with unimplemented ones getting exceptions from Perl rather than explicit
ones. Is there some pitfall in doing this?
Or I could just do a complete code-fork and have the two modules completely
unrelated other than happening to have many method names in common. This
loses improvements made to the superclass. But since any new methods would
have to be manually inspected for compatibility before adding them to the
redispatch list anyway, I am not sure this is really a meaningful problem.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.