Re: (declare (pure ...))

Pietro Cerutti <[email protected]>
Newsgroups gmane.lisp.scheme.chicken
Message-ID <0107018d9251c6cc-681ed9d4-9d0e-44f7-8d18-289d7847a9e9-000000@eu-central-1.amazonses.com>
> On 10 Feb 2024, at 09:27, Al <[email protected]> wrote:
> 
> On 2024-02-10 10:13, Pietro Cerutti wrote:
> 
>> 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.
>> 
> Those two things are the same thing in Haskell and languages that have a mathematical model of the program, yes. Scheme is... not that, much of the time. Chicken is implemented on top of C, so it's even less clear.

Both Haskell and CHICKEN ultimately compile to obiect code. That is not important: the important thing is the abstract machine you're programming against. This is why I specified "observable" in my previous reply.

> But let's not get theoretical, yes, my question is if csc can (does?) "memoize" the results of "pure" function.
> 
> 
> In any case, the definitions I quoted above
> 
> * https://wiki.call-cc.org/man/5/Declarations#pure
> 
> * https://wiki.call-cc.org/man/5/Types#purity
> 
> are not the same thing, so either the one or the other should stand. Though I'm not sure what "local variables or data contained in local variables" actually means. I think it means you can't "set!" globals.

Yeah their wording is different but the meaning is the same, i.e., a --> function will be marked as pure (for the implementation, see the last value returned by validate-type in scrutinizer.scm).

-- 
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.