You aren't the only person that didn't understand me, so it must be my fault. I did fumble a bit with the wording when I was trying to spit it out, so let me try again.
The main issue is that I have one superclass that might be subclassed by four or five classes, and each of those might be subclassed by four or five classes. Each class at each level needs to implement do_something(). So, if I have A::B::C, then there needs to be a C::do_something, B::do_something, and A::do_something. Additionally, C::do_something needs to recursively call B::do_something, etc.. Also, I want the external behavior of my API to be alike for all of the do_something methods. Somebody using my group of modules should not need to know if they are presently using an A::B::C object or an A::B::D object, all they need to know is that $object->do_something() will do something consistently for all objects that inherit from A.
What I have discovered is that in my case, the only difference between each of the do_something methods are a couple of constants that I already know at compile time.
If the only thing that makes each of the methods different is a couple of constants, I was hoping that I could use closures to generate my code for me in each module, rather than having to implement a stub for the method in every module.
I'm sure a good bit of the confusion stems from my lack of experience with closures. So please accept my appologies for that. Hopefully I've explained myself better this time.
In reply to Re: Re: Trying to re-use code at different levels of an inherited object.
by ehdonhon
in thread Trying to re-use code at different levels of an inherited object.
by ehdonhon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |