[Python-3000] PEP 3124 - Overloading, Generic Functions, Interfaces, etc. (original) (raw)
Greg Ewing greg.ewing at canterbury.ac.nz
Thu May 10 23:59:07 CEST 2007
- Previous message: [Python-3000] PEP 3124 - Overloading, Generic Functions, Interfaces, etc.
- Next message: [Python-3000] PEP 3124 - Overloading, Generic Functions, Interfaces, etc.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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" or "primary".
For that matter, what if there is simply another decorator @Foo that is defined to alwaysoverride @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.
-- Greg
- Previous message: [Python-3000] PEP 3124 - Overloading, Generic Functions, Interfaces, etc.
- Next message: [Python-3000] PEP 3124 - Overloading, Generic Functions, Interfaces, etc.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]