[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] Re: Yet another callback system proposal


> - callbacks are called starting from the object and then up the inheritance tree
>     - so if we have a prerun method registered at the
>       object level, it will be called first, and then any prerun
>       methods in the current class, and then upwards
>       in order until we hit the CGI::Application class
>     - this means the standard cgiapp_prerun method will be
>       called last!

Wouldn't it make more sense have the execution order go the other way
round (from general to specific)?  Superclasses might set up features
that subclasses might want to use.

As for implementation, is there an easy way to do this without requiring
Class::ISA?  My patch didn't deal at all with the order of classes in
the hierarchy.  It sorted callbacks based on numeric position only.  If
two callbacks were installed at the same position, then they would get
run in an arbitrary order (at that position).

This meant I could use UNIVERSAL::isa to skip callbacks installed by
unrelated classes, but I didn't need to generate the ordered ISA tree.

AFAIK, Class::ISA is a core module on 5.8.x, but not on 5.6.x or
earlier.

I guess our options are:

   - don't use Class::ISA at all.  Either re-implement it, or find some
     other way to determine class order, or find some implementation
     that doesn't care about the order of classes in the hierarchy.

   - use Class::ISA and make it a prerequisite in Makefile.PL

   - only require Class::ISA at runtime when someone first calls
     add_callback


>     - what about multiple inheritance?  Does that pose a problem?

It looks like Class::ISA handles multiple inheritance fine.  Without
Class::ISA, I imagine it would be bit of a pain to build the inheritance 
tree when multiple inheritance is involved.

> If anyone has some time to hammer something out, I would appreciate
> it, 'cause I have a potentially busy weekend ahead of me.  It may be
> sufficient to take Michael's latest patch and just remove and rework
> the order of execution.
>
> Also if anyone can come up with some good tests for the test suite
> that would be very helpful (maybe they are already floating around in
> one of the patches).

If we can sort out the Class::ISA issue, I will be happy to write a
first draft of the callbacks patch (including docs and tests), but I
probably won't get to it until Monday or Tuesday.


Michael


-----------------------------------------------------------------------
Michael Graham <suppressed>

YAPC::NA 2005 Toronto - http://www.yapc.org/America/ - suppressed
-----------------------------------------------------------------------


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.