(side-)effects and ...

Chris Angelico rosuav at gmail.com
Mon Jul 6 02:38:54 CEST 2015


On Mon, Jul 6, 2015 at 6:29 AM, Stefan Ram <ram at zedat.fu-berlin.de> 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()«?
>
>   And this is the intention of my post: Maybe there is such
>   a term, and I just missed to learn it so far? So,
>   do you know a term for the phenomenon that can be found
>   in Python but not in mathematics and consists in the state
>   of the world influencing the value of an expressions?

The Pike optimizer short-cuts this by flagging such functions as "have
side effects". As far as optimizers are concerned, there's not a lot
of difference between print() and time(); both of them need to be
called every time they're written (unlike, for instance, math.sin(1)
which can be called once and then replaced with its result, as it's a
pure function). Not sure this helps, but it might indicate why there's
no real term for it - "side effects" kinda can be stretched to mean
both directions.

ChrisA


More information about the Python-list mailing list