[Python-Dev] Call for defense of @decorators
ronaldoussoren at mac.com
Thu Aug 5 21:54:17 CEST 2004
On 5-aug-04, at 21:45, Neil Schemenauer wrote:
> On Thu, Aug 05, 2004 at 09:28:13PM +0200, Ronald Oussoren wrote:
>> On 5-aug-04, at 21:17, Gustavo Niemeyer wrote:
>>> def funcname(...):
>>> funcname.signature = "v@:@i"
>> That should be workable for this specific example.
> Even nicer if '_' is bound to the last function defined.
> class SomeClass(objc):
> def funcname(...):
> _.signature = "v@:@i"
> The objc metaclass could take the 'signature' function attribute and
> transform the function.
>> It wouldn't work for the objc.accessor example. The objc.accessor
>> function/decorator deduces the right kind of signature from the
>> name and arguments of the function.
> Can't the metaclass do that?
Not every method is a property accessor. The metaclass does calculate a
default signature (all arguments are objects and the result is an
object) when it doesn't have better information (such as the signature
of a method with the same name in a superclass). Sadly enough that
isn't good enough for property setters. Some parts of Cocoa require
that a setter returns 'void'.
I'm trying to push the automatic detection of the right signature as
far as I can get to avoid having to use explicit annotations in user
code, but sometimes you just cannot avoid adding annotations.
X|support bv http://www.xsupport.nl/
T: +31 610271479 F: +31 204416173
More information about the Python-Dev