Decorator syntax (was Re: PEP 318 - PyFIT comments)

Bruce Eckel BruceEckel at MailBlocks.com
Wed Aug 4 21:00:26 EDT 2004


I'll weigh in a little on this one.

This is very similar to attributes/metadata in Java J2SE 5 and in C#.
The thing is, metadata is a little bit weird; it's intentionally
outside of the domain of the 'normal' programming language, because it
expresses things that you can't or shouldn't within the normal
programming language. So you _do_ need an escape mechanism. And it
also takes a little bit of getting used to; it's orthogonal to what
you normally think of as a language feature. But the potential for
metadata features, at least in Java, is very powerful.

I suspect that the influence comes from Java, where they are also
using '@' (I don't recall what C# uses but it's very possibly also
'@'), and this was, I believe, one of the last things put into J2SE
1.5, so (guessing again) I suspect that's why it showed up so late in
Python -- the last thing I saw presented was attributes inside square
braces, and the only question was where they should go.

You can certainly argue that I'm more comfortable with it because I'm
already familiar with and used to the '@' syntax and actually think it
may be an improvement over [] because it may be more flexible -- at
least it is in Java.

I understand that many are uncomfortable with this feature and idea
and syntax, but I think we'll find it has compelling value, and the
fact that it is in both Java and C# (actually, it was invented for C#
by Anders, I believe, and Java is catching up), and that it fills a
need in Java that people were inventing comment syntax for, makes it
worth considering.

Bruce Eckel





More information about the Python-list mailing list