Alternative decorator syntax - POLL RESULTS SO FAR - ARE WE DONE?

M

Mahesh Padmanabhan

[snip]

As an occasional lurker, I haven't had a chance to participate in the
discussion about decorator syntax but for what its worth, I prefer the
J2 syntax over the @pie syntax. It just seems more natural to me. When I
first looked at the @pie syntax, I hoped that Guido would not include it
as it reminded me too much of Perl black magic.

Anyway, my vote is for the J2 option and "using" as the keyword seems to
be the best fit for this option.

Regards,
Mahesh
 
N

Nicolas Chauvat

Hi,

Le 22-08-2004 said:
Well, after 3 days of open polling, the number of additional votes have
dropped off pretty dramatically. Here are the results so far:

Total voters: 55 (with 3 votes each)

Here is my vote, in case it can still be included.

C2 C2 J2

Concerning the choice of the keyword, I'd vote *against* decorate and for
something like predef (J2), with (C2, J2), using (C2).

Concerning the @-thingy, it's the worst proposal I have ever heard concerning
Python. Sounds too cryptic to be true... must be a joke.

I'd like to add that the EuroPython poll was clearly in favor of *not* using
the @thing in front of functions and that this poll results also said that
people would rather not include the "decorator" feature in the next
release than include it as described.

Last but not least, the best option would IMHO not to implement so-called
decorators without thinking seriously about what they are supposed to do
exactly, as title 7 says at http://www.python.org/moin/PythonDecorators

In other words "it's getting urgent to wait".
 
J

Jess Austin

Arien Malec said:
"transform:"

In general:

Something that is either semantic neutral, or makes semantics explicit.

A verb of neutral meaning, like "transform", seems more likely to
cause difficulty with old code. I would expect there to be hundreds
of Python functions in use right now with the name "transform",
because that verb encompasses many things that functions often do. A
function may be called at any level of indentation, and there would be
no way for the parser to distinguish a function call from a
decoration. This same objection can be voiced about any keyword, and
is the reason why this option would definitely entail an "from
__future__ import decorators", but many words would conflict less than
"transform".

Another objection that has been raised about my current favorite,
"decorate", is that at 8 characters it's too long. 9 characters will
also be considered too long by a number of people.

The natural short version of "decorate" would be "dec" and there is
sort of a natural parallelism with "def" there. I hesitate to
nominate it because it _feels_ like a word that at least ten people on
c.l.py will detest.

Maybe "decor"? It isn't any longer than "class", and I think we can
predict it will be typed less than 1/10 as often. But this reasoning
could also excuse "decorate", so I'll stick with that. I'm also open
to any transitive verb that can be designated to mean _exactly_ what
"decorate" means now.

later,
Jess
 
A

Anthony Baxter

The natural short version of "decorate" would be "dec" and there is
sort of a natural parallelism with "def" there. I hesitate to
nominate it because it _feels_ like a word that at least ten people on
c.l.py will detest.

'dec' is also going to clash with a lot of code that uses that. That's going
to be a problem with pretty much any short keyword.
Maybe "decor"? It isn't any longer than "class", and I think we can
predict it will be typed less than 1/10 as often. But this reasoning
could also excuse "decorate", so I'll stick with that. I'm also open
to any transitive verb that can be designated to mean _exactly_ what
"decorate" means now.

decor is better - I can't find any uses of it in the Python code I just grepped
over...
 
P

Paul Rubin

Anthony Baxter said:
'dec' is also going to clash with a lot of code that uses that. That's going
to be a problem with pretty much any short keyword.

I really am liking J2 less and less. Even @pie seems more natural.
The best in my opinion is still J4 with no keyword.
 
E

Eli Stevens (WG.c)

Jess said:
Another objection that has been raised about my current favorite,
"decorate", is that at 8 characters it's too long. 9 characters will
also be considered too long by a number of people.

The natural short version of "decorate" would be "dec" and there is
sort of a natural parallelism with "def" there. I hesitate to
nominate it because it _feels_ like a word that at least ten people on
c.l.py will detest.

Maybe "decor"? It isn't any longer than "class", and I think we can
predict it will be typed less than 1/10 as often. But this reasoning
could also excuse "decorate", so I'll stick with that. I'm also open
to any transitive verb that can be designated to mean _exactly_ what
"decorate" means now.

J2 J2 F, but I'm a lurker and Python newbie, so... ;)

I kind of like the keyword "alter", but I suspect that, like many other
such words, it will conflict quite a bit with existing code. One of the
issues that some have raised was the disconnect between the "using" and
"def" lines. What about copying the pattern used by if/elif; something
like (I like the first the best, I think it "reads well," while the
second is the shortest and has a nice rhythm):


alterdef:
classmethod
def foo():
pass


decdef:
classmethod
def foo():
pass


decoratedef:
classmethod
def foo():
pass


Of course, this will mean that there would also be an "alterclass:" if
classes need decorators (in this case, "decclass:" doesn't seem as nice,
and reusing "alterdef:" is downright misleading).

Just a thought,
Eli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,967
Messages
2,570,148
Members
46,694
Latest member
LetaCadwal

Latest Threads

Top