[Python-3000] PEP 3124 - Overloading, Generic Functions, Interfaces, etc.
greg.ewing at canterbury.ac.nz
Thu May 10 23:59:07 CEST 2007
Phillip J. Eby wrote:
> As I said above (and in
> the PEP), *all* before and after methods are always called, unless an
> exception is raised somewhere along the way.
> "Before" methods are invoked most-specific method first, with
> ambiguous methods being executed in the order they were added. All
> "before" methods are called before any of the function's "primary"
> methods (i.e. normal ``@overload`` methods) are executed.
Well, it wasn't clear to me at all from the PEP that
this is how it works. The above paragraph doesn't say
anything about @around methods, for example, and it's
not obvious whether they should be considered "normal"
>> For that matter, what if there is simply another
>> decorator @Foo that is defined to always_override
>> @Around? The precedence between that and your
>> @Debug decorator then appears to be undefined.
> If so, then you'll get an AmbiguousMethods error (either when defining
> the function or calling it) and thus be informed that you need another
> override declaration.
I can see a problem with this. If Library1 defines a
method that always overrides an @around method, and
Library2 does the same thing, then if I try to use
both libraries at the same time, I'll get an exception
that I don't know the cause of and don't have any
idea how to fix.
More information about the Python-3000