[Python-Dev] Re: Call for defense of @decorators (original) (raw)
"Martin v. Löwis" martin at v.loewis.de
Mon Aug 9 08:14:22 CEST 2004
- Previous message: [Python-Dev] Re: Call for defense of @decorators
- Next message: [Python-Dev] Re: Call for defense of @decorators
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Christian Tismer wrote:
What I added was yet another stuff entry for new-style classes. It may also appear on module level, like the metaclass feature works.
While this "works", I still think it is a bad idea, for two reasons:
- It only helps the parser, A human reader would have to scroll to the top of the class (or worse, to the top of the module) to find out.
- For the author, it is redundant typing - the author knows this is a decorator, so having to type this again in full is redundant. 1 and 2 together make this a write-only syntax.
- It means that the parser has to recognize decorators This is not often the case; I believe the only other exception is future (which I also dislike, despite its cuteness). [As any good list of 2 reasons, this list of course has 3]
But it provides a solution without enforcing us to decide about new syntax right now, which appears to be too early for a group that can't find a common denominator, yet.
There is a solution already: put the function wrappers after the declaration. The goal of this change is specifically to come up with a syntax. If no syntax could be find, it would be best not to change anything.
I'm not worried that the group cannot agree on syntax: people can never agree on syntax, not just in the case of Python. If you wait for agreement, you wait forever.
For my purposes it works fine, but I don't claim that it fulfils all other desired use cases. At least it is compatible, simple, complete, implemented in a way, and works for my applications.
It's not any more compatbible than the 2.4a2 approach:
- old code (which does not use the feature) continues to work correctly (*)
- new code (which uses the feature) won't work on old implementations. (*) Actually, there is a slight incompatibility in your approach: Code that used to run and used to raise an exception would, under your change, now suddenly succeed without exception.
Regards, Martin
- Previous message: [Python-Dev] Re: Call for defense of @decorators
- Next message: [Python-Dev] Re: Call for defense of @decorators
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]