[Python-Dev] Vote No on 318

Raymond Hettinger python at rcn.com
Thu Apr 1 15:47:26 EST 2004


[Michael]
> > We've been discussing this off and on for OVER A YEAR!  If 'the best
> > syntax' hasn't been figured out yet after N thousand emails on the
> > subject, I see no reason to believe enlightenment is going to arrive
> > soon (or ever).

[Jeremy]
> There's no particular reason to believe that effort alone will arrive
at
> an elegant solution.  On the other hand, maybe there isn't a good
syntax
> for arbitrary decorators.

IMHO, the best syntax is what we have now.  Its only weakness is being
distant from the first line in the definition.  Other than that, it is
understandable, unambiguous, simple, backward compatible, and flexible.

A failing common to all of the proposals is that they turn action words
(like classmethod) into adjectives with implicit actions.  By making
them implicit, it becomes less obvious what is occurring, when it is
occurring, and, for multiple decorators, which order they occur.  That
will make the wrapped functions harder to debug.

A second failing is introducing a second way to do it.  The current
approach will always be there for some purposes, properties,
metaclasses, existing code, or dynamic wrapping.  This is a prime
example where two ways to do something is especially bad; if you do not
see [staticmethod] in the definition, can you presume that it is not a
staticmethod -- the answer is clearly no.   So, why create optical
illusions.

A third failing is clashing with a design preference for
functions/expressions over statements/keywords/syntax.  This concept was
at the foundation for discussions about having a print() function, using
sorted() in an expression, or implementing if-then-else expressions.  My
understanding of language design history is that of regrets for not
using functions wherever possible.

Also, some proposed uses were strange enough that I wonder whether the
syntax encourages people to do weird things with their code.

How much complexity has to be introduced just to bring decorations
closer to the first line in a definition?


Raymond Hettinger
Chairman, Citizens Against 318


#################################################################
#################################################################
#################################################################
#####
#####
#####
#################################################################
#################################################################
#################################################################



More information about the Python-Dev mailing list