[Python-ideas] Statically checking purity of functions

Sven R. Kunze srkunze at mail.de
Fri Jun 10 06:16:15 EDT 2016


On 09.06.2016 21:48, Robert Collins wrote:
> The problem, as Cory demonstrates, is that purity is transitive: you
> have to know that all the runtime interactions are also pure, or your
> function stops being pure.

That reminds me of the discussion in the other thread about (im-)mutability.

>
> external names like random in add_random can never be pure (because
> any piece of impure code can change the module globals to rebind
> random to something else). This means that any pure function would
> have to accept as parameters everything it operates on, and you'd need
> to error on any call to a pure function with impure arguments. It
> would be an interesting exercise to see how it plays out in practice
> though.


More information about the Python-ideas mailing list