[Python-3000] PEP 3124 - Overloading, Generic Functions, Interfaces, etc.

Jim Jewett jimjjewett at gmail.com
Thu May 3 16:16:53 CEST 2007


On 5/3/07, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:

> I don't doubt that things like @before and @after are
> handy. But being handy isn't enough for something to
> get into the Python core.

I hadn't thought of @before and @after as truly core; I had assumed
they were decorators that would be available in a genfunc module.

I'll agree that the actual timing of the super-call is often not
essential, and having time-words confuses that.  On the other hand,
they do give you

(1)  The function being added as an overload doesn't have to know
anything about the framework, or even that another method may ever be
called at all; so long as the super-call is at one end, the
registration function can take care of this.

(2)  The explicit version of next_method corresponds to super, but is
uglier in practice, becaues their isn't inheritance involved.  My
strawman would boil down to...

    def foo():...
        next_method = GenFunc.dispatch(*args, after=__this_function__)

Note that the overriding function foo would need to have both a
reference to itself (as opposed to its name, which will often be bound
to somthing else) and to the generic function from which it is being
called (and it might be called from several such functions).
Arranging this during the registration seems like an awaful lots of
work to avoid @after

-jJ


More information about the Python-3000 mailing list