Alternative decorator syntax decision

Paul McGuire ptmcg at austin.rr._bogus_.com
Fri Aug 20 18:29:48 EDT 2004


> >
> > I personally find J2 worse than the current pie
> > syntax. Something that looks odd and does something
> > odd seems the lesser evil vs something that looks
> > normal yet does something odd.
>
Why is decorating a function by wrapping it with some "helping" logic of
some sort perceived to be "odd"?

I would guess that generators and list comps were thought "odd" by some when
they were proposed, too, but we have acclimated ourselves to their concepts,
and embraced them.  I'm sure part of this receptiveness was the fact that
the selected syntax did not include some eye-jarring splat of punctuation.

But '@' will forever look odd, even after we have accustomed ourselves to
the utility of function decoration, with the likes of memoize, etc.

If you truly feel function decoration is an "odd" thing, why is it getting
into the language at all?  Why not instead look ahead to when function
decoration is accepted as part of the rich toolkit of power Python
programming, and marvel at how seamlessly it blends into the syntactic
terrain.  I think the only way this can happen is to incorporate decorators
while maintaining the clean consistency of its syntax forms: source
indentation to indicate hierarchy of logic (or declaration); conventional
punctuation, such as [], :, and (); native data type constructs, such as
lists and dictionaries; powerful class definition tools.

Just because Java uses @ for declaring new function attributes does not sway
me towards accepting it - I don't see us adopting {}'s in place of
indentation, even though C, C++, Perl, and Java all use them.  I see the
absence of '@' in Python to be a *good* thing, and I hope hope hope that it
will stay *out* of the language.

-- Paul





More information about the Python-list mailing list