[Python-3000] PEP 3124 - Overloading, Generic Functions, Interfaces, etc. (original) (raw)
Talin talin at acm.org
Wed May 2 04:21:28 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:
At 09:13 AM 5/1/2007 -0700, Talin wrote:
Phillip J. Eby wrote:
Proceeding to the "Next" Method ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If the first parameter of an overloaded function is named
_proceed_, it will be passed a callable representing the next most-specific method. For example, this code:: def foo(bar:object, baz:object): print "got objects!" @overload def foo(proceed, bar:int, baz:int): print "got integers!" return proceed(bar, baz)I don't care for the idea of testing against a specially named argument. Why couldn't you just have a different decorator, such as "overloadchained" which triggers this behavior? The PEP lists five built-in decorators, all of which support this behavior:: @overload, @when, @before, @after, @around And in addition, it demonstrates how to create new method combination decorators, that also support this behavior (e.g. '@discount'). All in all, there are an unbounded number of possible decorators that would require chained and non-chained variations.
Well, I suppose you could make "chained" a modifier of the decorator, so for example @operator.chained, @discount.chained, and so on. In other words, the decorator can be called directly, or the attribute 'chained' also produces a callable that causes the modified behavior. Moreover, this would support an arbitrary number of modifiers on the decorator, such as @overload.chained.strict(True).whatever.
-- Talin
- 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 ]