Re: (declare (pure ...))

Pietro Cerutti <[email protected]>
Newsgroups gmane.lisp.scheme.chicken
Message-ID <0107018d92140e58-d2743b8f-c8ad-4cda-a21a-f50f1290b19b-000000@eu-central-1.amazonses.com>
> On 10 Feb 2024, at 09:06, Al <[email protected]> wrote:
> 
> 
>>> * only side-effect free, or ...
>>> 
>>> * also return the same value when called with the same arguments?
>> 
>> The first implies the second: to be able to choose from a set of return values for the same given argument, you do need to have side-effects, e.g., interact with a RNG which maintains state, read from a file, maintain an index into a circular vector of results, etc..
>> 
>> Here's what the docs say:
>> http://wiki.call-cc.org/man/5/Declarations#pure
>> 
> "referentially transparent, that is, as not having any side effects". You can read "the environment" (including all globals) without actually modifying the environment. Between two applications of the procedure, other impure procedures may modify the environment. So it's not clear if it means Haskell monad purity or immutable purity, hence my question.

I don't get your question: those two things are the same thing :)

Referential transparency means you can substitute an expression with its expansion down to a value. If anything happening in between causes (observable *) changes, you can't do it anymore.

(*) modifying the program counter is not an observable change, for example.


-- 
Pietro Cerutti
I've pledged to give 10% of income to effective charities and invite you to join me.
https://givingwhatwecan.org

Sent from a small device - please excuse brevity and typos.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.