Re: Python-Dev Digest, Vol 8, Issue 107
On Wed, 2004-03-31 at 12:52, python-dev-request@python.org wrote:
Message: 6 Date: Wed, 31 Mar 2004 12:49:14 -0800 From: Guido van Rossum
Subject: Re: [Python-Dev] PEP 318: Decorators last before colon To: "Phillip J. Eby" Cc: python-dev@python.org Message-ID: <200403312049.i2VKnEi14444@guido.python.org> There appears to be a strong correlation between people who have specific use cases for decorators, and the people who want the last-before-colon syntax. Whereas, people who have few use cases (or don't like decorators at all) appear to favor syntaxes that move decorators earlier. Whether that means the "earlier" syntaxes are better or worse, I don't know. <0.5 wink>
Maybe the practitioners are so eager to have something usable that they aren't swayed as much by esthetics.
The current system with no syntax is equally usable, what's gained functionally? This argument was and is often used against interface syntax; it's a strong argument. In the case of interfaces the argument was against one nine letter keyword that could not possibly be confused with a list or anything else. This syntax is riskier.
The human brain is a lot more flexible in picking up patterns than the Python parser; as shown many times in this discussion, most people have no clue about the actual syntax accepted by the Python parser, and simply copy (and generalize!) patterns they see in examples.
Or like me, they just do what Emacs tells 'em, which does argue for decorators of any or no syntax. Javadoc coming before a method is another precedent in favor of something coming before, but these are without run-time function.
It also seems to be working against the AST branch a bit, in that I would expect the decorator expressions to be part of the function definition node, rather than in an unrelated statement.
Another discussion point occurred to me regarding interfaces and projects that use them heavily like Zope, Twisted, PEAK etc. Has the decorator syntax as proposed been evaluated in the light of these interfaces (and any future native language support for them), whose methods have no body to interpose between the definition and decorators as they exist now? I've seen the "Large Body" argument use several times in defense of the decorator syntax being before or above the definition. -Michel
At 03:18 PM 3/31/04 -0800, Michel Pelletier wrote:
On Wed, 2004-03-31 at 12:52, python-dev-request@python.org wrote:
Message: 6 Date: Wed, 31 Mar 2004 12:49:14 -0800 From: Guido van Rossum
Subject: Re: [Python-Dev] PEP 318: Decorators last before colon To: "Phillip J. Eby" Cc: python-dev@python.org Message-ID: <200403312049.i2VKnEi14444@guido.python.org> There appears to be a strong correlation between people who have specific use cases for decorators, and the people who want the last-before-colon syntax. Whereas, people who have few use cases (or don't like decorators at all) appear to favor syntaxes that move decorators earlier. Whether that means the "earlier" syntaxes are better or worse, I don't know. <0.5 wink>
Maybe the practitioners are so eager to have something usable that they aren't swayed as much by esthetics.
The current system with no syntax is equally usable, what's gained functionally?
It's not equally usable. It is 1) considerably more verbose, particularly in Bob's use case of long function names, and 2) hard to spot by a reader who's skimming to get an overview of a class or module.
Another discussion point occurred to me regarding interfaces and projects that use them heavily like Zope, Twisted, PEAK etc. Has the decorator syntax as proposed been evaluated in the light of these interfaces (and any future native language support for them), whose methods have no body to interpose between the definition and decorators as they exist now? I've seen the "Large Body" argument use several times in defense of the decorator syntax being before or above the definition.
I have seen virtually no use of decorators on interface methods in the frameworks you mention. In fact, I can't recall ever having seen a single use of decorators on interface methods. That's probably simply because the cost of using decorators is too high to waste on anything that's not part of the implementation, and the documentary value of decorators using today's syntax is poor compared to adding text to the method's docstring.
On Wed, 2004-03-31 at 16:23, Phillip J. Eby wrote:
The current system with no syntax is equally usable, what's gained functionally?
It's not equally usable. It is 1) considerably more verbose, particularly in Bob's use case of long function names, and 2) hard to spot by a reader who's skimming to get an overview of a class or module.
Both true. Perhaps I should have said functionally equal. The proposed syntax is more usable from a syntax perspective, I agree, but offers no more "use" once you have the object in hand, so to speak. The aesthetics is another matter I've already voiced my opinion on.
Another discussion point occurred to me regarding interfaces and projects that use them heavily like Zope, Twisted, PEAK etc. Has the decorator syntax as proposed been evaluated in the light of these interfaces (and any future native language support for them), whose methods have no body to interpose between the definition and decorators as they exist now? I've seen the "Large Body" argument use several times in defense of the decorator syntax being before or above the definition.
I have seen virtually no use of decorators on interface methods in the frameworks you mention. In fact, I can't recall ever having seen a single use of decorators on interface methods. That's probably simply because the cost of using decorators is too high to waste on anything that's not part of the implementation,
I think there must be *some* decorators valid for interfaces. What about proposed decorators like "synchronized"? Are these part of the interface? Or something equivalent to Java's "throws", arguably a decoration and arguably part of a method's interface. What about decorations that can *never* be used in an interface, like "classmethod"? Would an error be raised if you tried to decorate an interface method with a classmethod decorator? I don't think any of these things refute or validate the need for special syntax, I just wonder if it's been thought about enough, and that goes way beyond the syntax. -Michel
participants (2)
-
Michel Pelletier
-
Phillip J. Eby