There's more than one way to do things | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Very nice meditation and very interesting technique (I took a look at some of the "guts" of it here as well). However I must say that it seems like a lot of overhead in single inheritance situations. This is the dreaded "diamond inheritance" problem: if Base provides a compile() method, which Filter and Safe each override to perform additional actions around a call to SUPER::compile, how can we ensure they are all called in sequence? In my experience, it is not usually just an issue of FilterSafe calling them in the right sequence, but doing what you say Filter and Safe do and performing additional actions around calls to the superclass's compile method. So while many times I would like to be able to just use something like NEXT, I find that I must instead do things like $self->Filter::compile() and $self->Safe::compile() instead. And to be honest this no longer bothers me, and I have now learned to see it as an elegant way to specifically direct method dispatch in the presences of multiple inheritance. However, your medition got my mind moving and I decided to see if I couldn't create a simple NEXT-ish type module which would dispatch to all the superclasses in the same order as the modules were inherited, and without some of the odd craziness which NEXT seems to require (in the examples all calls go through NEXT:: even in the base classes and single inheritance classes).
I am not sure if this would solve the specific problem you have though, but it does solve the "diamond inheritance/called in sequence" issue you mention. Anyway, back to work, thanks for the mental jumpstart, very nice meditaion.
-stvn
In reply to Re: Solving the SUPER problem in Mixins with String Eval
by stvn
|
|