Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #93513
| From | Robert Kern <robert.kern@gmail.com> |
|---|---|
| Subject | Re: (side-)effects and ... |
| Date | 2015-07-06 00:44 +0100 |
| References | <effects-20150705220525@ram.dialup.fu-berlin.de> <20150705153625.263a3b21@bigbox.christie.dr> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.309.1436139866.3674.python-list@python.org> (permalink) |
On 2015-07-05 21:36, Tim Chase wrote: > On 2015-07-05 20:29, Stefan Ram wrote: >> But why do we not have a common and well-known term for >> the counterpart, that something does not modify the state >> of the world, but that the state of the world does >> influence the value (behaviour) of a call such as >> »datetime.datetime.now().time()«? > > I believe the term is "idempotent" > > https://en.wikipedia.org/wiki/Idempotent_function#Computer_science_meaning No, "idempotent" means that if it changes the state, then applying it twice or more has the same effect as applying it once. For example, calling object.__setattr__(self, attr, y) with the same arguments is idempotent; whether you execute that once, twice or N times, afterwards, `getattr(self, attr) is y`. But calling it the first time probably did make a change of state. This is unlike functions like list.append(self, x) which will give you different results depending on the number of times you call it, even if the arguments are the same. Functions that don't change state at all are naturally idempotent, but many idempotent functions do change state. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: (side-)effects and ... Robert Kern <robert.kern@gmail.com> - 2015-07-06 00:44 +0100
csiph-web