# from Christopher J. Madsen
# on Saturday 15 March 2008 17:55:
>$plugin->pre_METHOD($builder, $parameters, $context, $return)
>$plugin->post_METHOD($builder, $parameters, $context, $return)
>* To completely override a method, set $_[-1] to an appropriate value
> and return 'done'.
I don't like this return-by-reference scheme. Can we say that the
$return is an object and use methods for that?
return $return->done("foo");
Or perhaps the plugins could inherit from a base which defines done()
and continue() or so.
return $self->done("foo");
(For now, I'll pretend that done() sets a state in the object and
returns its argument.)
Of course, return() doesn't carry a consistent meaning in Module::Build
right now, so maybe that needs to be specified. What meaning should
return values have for plugins?
Also, note that die() is probably the best way to deal with an error
condition.
The priority and ordering are a concern when any plugin can abort the
action based on run order. This seems like it provides a lot of room
for subtle bugs. How would a plugin declare that it is incompatible
with another or otherwise avoid the silent error of "only one of my
plugins ran"?
>* Is this generic enough to be implemented in a separate module and
> re-used in other classes?
Possibly, but the "ACTION_" aspect and a few other things are going to
be somewhat specific to Module::Build. Perhaps building the
special-case first would be the way to get a better look at what the
general case would want.
So, do plugins only get hooks on "ACTION_*", or is everything hookable?
I'm a little concerned about what overhead is being added when no hooks
are defined (but I suppose we could redefine our method with a hooked
wrapper when a hook request appears.)
The requirement of get_hooks() is nice from M::B's reduced coding point
of view, but it requires the plugin author to repeat themselves. The
symbol-table grovelling seems warranted (even accounting for
inheritance) given that it only has to be written once and saves the
plugin author some wrote repetition. Perhaps this is get_hooks() in a
Module::Build::Plugins base class.
--Eric
--
"I've often gotten the feeling that the only people who have learned
from computer assisted instruction are the authors."
--Ben Schneiderman
---------------------------------------------------
http://scratchcomputing.com
---------------------------------------------------