I've been following the decorator debate with some interest, and it's taken
me a reasonably long time to understand what is meant by a decorator. One
of the issues is that the Decorator pattern is more like a Unix pipe than
it is what PEP 318 calls a decorator. The classic decorator is run-time,
rather than define time, and is non-destructive to the base function. The
PEP 318 decorator is define time and is a destructive change to the base
function. For instance, the GoF book makes it clear that decorators may be
added or removed without affecting the underlying class.
I personally think it's confusing to reuse the "Decorator" name for
something that is not a classic decorator. I also agree with the many
comments that the proposed syntax does not make it clear that what is going
on is a destuctive transformation of the defined function.
Arien 11 1560
On Fri, 13 Aug 2004 02:56:34 GMT, Arien Malec
<ar*********@ya hoo.com.REMOVE> wrote: I've been following the decorator debate with some interest, and it's taken me a reasonably long time to understand what is meant by a decorator. One of the issues is that the Decorator pattern is more like a Unix pipe than it is what PEP 318 calls a decorator. The classic decorator is run-time, rather than define time, and is non-destructive to the base function. The PEP 318 decorator is define time and is a destructive change to the base function. For instance, the GoF book makes it clear that decorators may be added or removed without affecting the underlying class.
I had first thought that the word used to describe the mechansim was
unimportant. "decorator" would come to mean, for Python, what Python
defined it to mean.
But have concluded otherwise. In fact using the word "decorator"
justifies the syntax, but - as you say - does not describe the impact
of that syntax in any reasonable way.
Its a bit of a con, I now think. I personally think it's confusing to reuse the "Decorator" name for something that is not a classic decorator. I also agree with the many comments that the proposed syntax does not make it clear that what is going on is a destuctive transformation of the defined function.
Apparently in the world of declarative programming it is kosher to
make @something mean a destructive transformation of a function
defined in its vicinity. When programming in Python. of course. And
without providing a cognative hint, or without the need to justify
itself by reference to any other notation that ever was.
That precedent, of course, opens up a world of new possibilities.
Unfortunately.
Art Arien
Arien Malec wrote: decorator. One of the issues is that the Decorator pattern is more
The term decorator as used in the current discussion comes from compiler
writing. You have a syntax 'tree' which gets 'decorated' with additional
attributes.
Daniel
"Daniel Dittmar" <da************ @sap.com> wrote in news:cfhsri$a1q $1
@news1.wdf.sap-ag.de: Arien Malec wrote: decorator. One of the issues is that the Decorator pattern is more
The term decorator as used in the current discussion comes from compiler writing. You have a syntax 'tree' which gets 'decorated' with additional attributes.
1) That's not mentioned in PEP 318
2) That's in disagreement with http://www.python.org/moin/PythonDecorators
3) Won't most programmers think GoF decorators before compiler syntax tree
decorators?
Arien
On 2004-08-13, Arien Malec <ar*********@ya hoo.com.REMOVE> wrote: decorator. One of the issues is that the Decorator pattern is more
The term decorator as used in the current discussion comes from compiler writing. You have a syntax 'tree' which gets 'decorated' with additional attributes.
1) That's not mentioned in PEP 318 2) That's in disagreement with http://www.python.org/moin/PythonDecorators 3) Won't most programmers think GoF decorators before compiler syntax tree decorators?
Thank you! I spent a while reading up on "decorators " the
other day and was completely baffled. I couldn't see that the
stuff in PEP 318 discussion threads had anything at all to do
with what was discussed by the references I found on
"decorators " (which were all about "design pattern" stuff).
So, I gave up and went back to work on writing a strip-chart
recorder using the Gnuplot module.
--
Grant Edwards grante Yow! I'm shaving!! I'M
at SHAVING!!
visi.com
1) That's not mentioned in PEP 318
We can fix that.
2) That's in disagreement with http://www.python.org/moin/PythonDecorators
That too (different authors, by the way).
Arien> 3) Won't most programmers think GoF decorators before compiler
Arien> syntax tree decorators?
Not if they are unfamiliar with the GoF patterns (myself included).
Skip
Skip Montanaro <sk**@pobox.com > wrote in
news:ma******** *************** *************** @python.org: Arien> 3) Won't most programmers think GoF decorators before compiler syntax tree decorators?
Not if they are unfamiliar with the GoF patterns (myself included).
Google:
decorate "syntax tree" -pattern --> 129 hits
decorator "syntax tree" -pattern --> 20 hits
decorator pattern -"syntax tree" --> about 62,000 hits
Arien
Arien> 3) Won't most programmers think GoF decorators before
Arien> compiler syntax tree decorators?
Skip> Not if they are unfamiliar with the GoF patterns (myself included).
Arien> Google:
...
BFD. Sure, there are tons more application programmers in the world than
compiler geeks, so Google returns many more hits for GoF-style decorators.
So? The thing is, just because in a verbal Rohrschach test you think "GoF"
when someone says "decorator" doesn't mean everybody else will (or should).
Hell, when someone says "decorator" I usually think of "Queer Eye for the
Straight Guy". <wink>
now-where-were-my-fabric-swatches?-ly, y'rs,
Skip
Skip Montanaro <sk**@pobox.com > wrote in
news:ma******** *************** *************** @python.org: Arien> 3) Won't most programmers think GoF decorators before Arien> compiler syntax tree decorators?
Skip> Not if they are unfamiliar with the GoF patterns (myself included).
Arien> Google: [~62,000 : ~130 mentions of each sort of decorator]
...
BFD.... The thing is, just because in a verbal Rohrschach test you think "GoF" when someone says "decorator" doesn't mean everybody else will (or should).
Clearly, Python can choose any name for the auto-function-transformation
syntax in question, but it's rather willfully confusing to choose a name
that's heavily identified with a profoundly different semantics that's
superficially similar in intent.
Arien
Arien Malec wrote: Skip Montanaro <sk**@pobox.com > wrote in news:ma******** *************** *************** @python.org:
Arien> 3) Won't most programmers think GoF decorators before Arien> compiler syntax tree decorators?
Skip> Not if they are unfamiliar with the GoF patterns (myself included).
Arien> Google: [~62,000 : ~130 mentions of each sort of decorator]
...
BFD.... The thing is, just because in a verbal Rohrschach test you think "GoF" when someone says "decorator" doesn't mean everybody else will (or should).
Clearly, Python can choose any name for the auto-function-transformation syntax in question, but it's rather willfully confusing to choose a name that's heavily identified with a profoundly different semantics that's superficially similar in intent.
Arien
This is especially confusing as, in everyday english usage, to decorate
is not the same as to transform.
Perhaps "transform" could be consdered as an alternative.
The Mad Hatter's response to Alice dealt with the root naming issue:
"When I use a word," Humpty Dumpty said in rather a scornful tone. "It
means just what I choose it to mean - neither more or less."
"The question is," said Alice, "whether you can make words mean so
many different things."
"The question is," said Humpty Dumpty, "which is to be master - that's
all."
Colin W. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Michael Sparks |
last post by:
Anyway...
At Europython Guido discussed with everyone the outstanding issue with
decorators and there was a clear majority in favour of having them, which
was good. From where I was sitting it looked like about 20:20 split on the
following syntaxes:
1 def func(arg1, arg2, arg3) :
function...
2 def func(arg1, arg2, arg3):
function...
|
by: daishi |
last post by:
For what it's worth:
As far as I know, the proposed @decorator syntax will be the first
time that two logical lines of python with the same indentation will
not be independent of one another. Previously, when looking at:
some_python(code)
and_some_more = stuff
there was no need to look at the the first line in order to know what
|
by: Michele Simionato |
last post by:
Decorators can generate endless debate about syntax, but can also
be put to better use ;)
Actually I was waiting for decorators to play a few tricks that were
syntactically too ugly to be even imaginable for Python 2.3.
One trick is to use decorators to implement multimethods. A while ago
Howard Stearns posted here a recipe to implement generic functions
a.k.a multimethods.
|
by: RebelGeekz |
last post by:
Just my humble opinion:
def bar(low,high):
meta:
accepts(int,int)
returns(float)
#more code
Use a metadata section, no need to introduce new messy symbols, or
mangling our beloved visual cleanliness of python.
|
by: Guido van Rossum |
last post by:
Robert and Python-dev,
I've read the J2 proposal up and down several times, pondered all the
issues, and slept on it for a night, and I still don't like it enough
to accept it. The only reason to accept it would be to pacify the
supporters of the proposal, and that just isn't a good enough reason
in language design.
However, it got pretty darn close! I'm impressed with how the
community managed to pull together and face the enormous...
| |
by: Anthony Baxter |
last post by:
To go along with the 2.4a3 release, here's an updated version of
the decorator PEP. It describes the state of decorators as they
are in 2.4a3.
PEP: 318
Title: Decorators for Functions and Methods
Version: $Revision: 1.34 $
Last-Modified: $Date: 2004/09/03 09:32:50 $
Author: Kevin D. Smith, Jim Jewett, Skip Montanaro, Anthony Baxter
|
by: km |
last post by:
Hi all,
was going thru the new features introduced into python2.4 version.
i was stuck with 'decorators' - can someone explain me the need of such a thing called decorators ?
tia
KM
|
by: Helmut Jarausch |
last post by:
Hi,
are decorators more than just syntactic sugar in python 2.x and what
about python 3k ?
How can I find out the predefined decorators?
Many thanks for your help,
Helmut Jarausch
|
by: Andrew West |
last post by:
Probably a bit of weird question. I realise decorators shouldn't be
executed until the function they are defined with are called, but is
there anyway for me to find all the decorates declared in a file when
I import it? Or perhaps anyway to find the decorators by loading the
file by other methods (with out simply parsing it by hand).
Basically what I'm looking for is a way to, given a python file, look
through that file and find all the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |