John M. Dlugosz has asked for the wisdom of the Perl Monks concerning the following question:
One approach is to have a special return value meaning "not for me".
Another approach, which is more flexible and good for a somewhat different class of problems, is to chain to the original (or earlier) function. The "hard way" is to set up my callback by getting the old value and saving that where my callback can see it, then setting my function as the new one to be called.
But I'm struck with how similar this is, conceptually, to "wrapper methods" and overrides of virtual functions in general. However, I don't want to derive a class to do it, and I want to supply the information per-instance.
But I can't help wondering if a similar mechanism would be useful for per-instance callbacks, either as a full-blown callback manager module, or at least employing these concepts in the design of how callbacks are supplied and possibly chained.
Anyone want to talk about it? Is there a better, modern, way to program callback features?
—John
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: chaining callbacks
by GrandFather (Saint) on May 07, 2011 at 06:16 UTC | |
by John M. Dlugosz (Monsignor) on May 07, 2011 at 07:04 UTC | |
|
Re: chaining callbacks
by anonymized user 468275 (Curate) on May 07, 2011 at 14:54 UTC |