Is there a way to change the closure of a python function?

Chris Angelico rosuav at gmail.com
Wed Sep 28 13:46:46 EDT 2016


On Thu, Sep 29, 2016 at 2:43 AM, Random832 <random832 at fastmail.com> wrote:
> On Wed, Sep 28, 2016, at 11:41, Paul Moore wrote:
>> What "allows side effects" in languages like Haskell is the fact that the
>> runtime behaviour of the language is not defined as "calculating the
>> value of the main function" but rather as "making the process that the
>> main functon defines as an abstract monad actually happen".
>
> Well, from another point of view, the output (that is, the set of
> changes to files, among other things, that is defined by the
> monad-thingy) is *part of* the value of the main function. And the state
> of the universe prior to running it is part of the input is part of the
> arguments.

That's exactly how a function works in an imperative language, and
it's exactly what the FP advocates detest: opaque state. So is the
difference between "function" and "monad" in Haskell the same as "pure
function" and "function" in other contexts?

ChrisA



More information about the Python-list mailing list