in reply to Solving the SUPER problem in Mixins with a Dispatch Method
At the risk of breaking ranks here, I will attempt to help actually answer your question, rather than lecture you about OO and the evils of MI (which no doubt you have already heard, and dont agree with (<sarcasm>persish the thought that one could disagree with the great OO idealouges</sarcasm>)).
Does anyone know how to reliably extract the name of the calling method, so that I can ommit that from the calls to the NEXT method? The ( caller(0) )3 can be hidden inside evals and such; do I just walk back through stack frames until I find one that's not an eval?
The docs for caller talk about how you could do this.
With caller(EXPR), it returns some extra information that the debugger uses to print a stack trace. The value of EXPR indicates how many call frames to go back before the current one.You will likely need to test a number of values to handle both the eval BLOCK and the eval EXPR and not have it get confused.Here $subroutine may be (eval) if the frame is not a subroutine call, but an eval. In such a case additional elements $evaltext and $is_require are set: $is_require is true if the frame is created by a require or use statement, $evaltext contains the text of the eval EXPR statement. In particular, for an eval BLOCK statement, $filename is (eval), but $evaltext is undefined. (Note also that each use statement creates a require frame inside an eval EXPR frame.) $subroutine may also be (unknown) if this particular subroutine happens to have been deleted from the symbol table.($package, $filename, $line, $subroutine, $hasargs, $wantarray, $evaltext, $is_require, $hints, $bitmask) = caller($i);
While I understand your hesitancy with AUTOLOAD, it would remove this entire problem. Also if you use the technique I showed in my post to your previous thread, in which you create a SUPER:: sub-package (which can easily be defined inline in your Base class), then you need not worry about having AUTOLOAD in any of you "real" classes.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Solving the SUPER problem in Mixins with a Dispatch Method
by simonm (Vicar) on Oct 14, 2004 at 17:32 UTC | |
by stvn (Monsignor) on Oct 14, 2004 at 18:20 UTC |