pep-318 questions
Hallvard B Furuseth
h.b.furuseth at usit.uio.no
Sat Aug 28 12:42:59 EDT 2004
Sorry with the late reply; when I got back to clp I had the silly idea
that I'd try to catch up with the decorator threads before answering...
Anyway,
Skip Montanaro wrote:
> Hallvard> The current syntax seems like the clear loser here too: No
> Hallvard> whitespace above the function name. Not too bad with a single
> Hallvard> decorator, but several is a problem.
>
> There's no requirement that you smash them all together. This is valid with
> the current patch:
>
> @ a
>
> # comment
> # comment
> # comment
> # comment
> @ b
>
>
> def func(*args, **kwds):
> ...
Which is even worse because one can easily miss some of the decorators
after locating the function.
> >> Finally, it would require the introduction of a new keyword.
>
> Hallvard> Actually, I'm wondering about that too.
>
> Nobody has so far been able to come up with a single keyword that seems to
> connote "this is a decorator function that is to be applied to the next
> function definition".
I thought the main objection to a keyword is that it breaks existing
code; I wasn't talking about _which_ keyword to choose.
My point is that maybe the J2 syntax does _not_ need to be a keyword.
It should work to recognize statements that begin with one word and a
colon, and treat that word as a pseudo-keyword in that statement. As
far as I can tell, that does not break anything: A valid statement
cannot begin with a non-keyword followed by a colon today.
That also makes 'apply' a candidate for the... pseudo-keyword, if anyone
still wants that one.
And if anyone wanted to, one could make 'else', 'try' and 'finally'
into non-keywords so they could be used as variables:-)
--
Hallvard
More information about the Python-list
mailing list