[Python-Dev] Call for defense of @decorators

Chris King colanderman at gmail.com
Thu Aug 5 23:01:38 CEST 2004


On Thu, 05 Aug 2004 22:53:28 +0200, "Martin v. Löwis"
<martin at v.loewis.de> wrote:
> Chris King wrote:
> > Isn't this more a use case for function attributes, rather than
> > decorators?  Decorators seem like overkill in this case.
> 
> In the specific case, I believe declaring the Objective-C
> signature also performs some kind of registration of the
> function with the Objective-C run-time. This cannot be done
> with function attributes; you would still need to invoke
> a do_register()/generate_wrappers() functions at some point.

I held off posting that at first because of this (since I am not at
all familiar with PyObjC), but then Ronald mentioned something about
the registration and processing being done via a metaclass, rather
than by the decorators themselves.

> Even if this is a mere declaration, function attributes would
> harm readability: they would have to go after the function, whereas
> you want the Objective-C signature close to the Python signature.

I should have been more specific -- I meant function attributes of
this form (proposed and subsequently rejected somewhere else a while
ago):

def foo(a,b,c):
    .signature = 'v@:@i'
    pass

I only bring this up because most (though I realize not all) use cases
for decorators (at least in their current form) seem to involve some
type of attribute or metadata.


More information about the Python-Dev mailing list