[Python-Dev] Call for defense of @decorators

"Martin v. Löwis" martin at v.loewis.de
Thu Aug 5 21:07:55 CEST 2004


Gustavo Niemeyer wrote:
> Is special syntax in the language really required in this case,
> considering you're already doing something "fairly magic" anyways?

The syntax is not special for the specific application (Objective-C),
but special for a class of applications (modifications of/annotations
to the subsequent function).

> What is objc.signature() doing?

I'm only guessing here: it declares an Objective-C signature (i.e.
a type) of the function. This is probably necessary for thunking.

I can't see a way to do that in a comprehensible way without a
decorator. It applies to the function, and it probably needs to
wrap the function. So without a special syntax, it would have to
go after the function. This is counter-intuitive, as the Objective-C
signature has to correspond (I guess) with the Python signature,
so it is desirable that they are closely together.

It might be possible to put that annotation into the __doc__ string,
but that would be abusing doc strings, and might be more error-prone.

Regards,
Martin


More information about the Python-Dev mailing list