chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (declare (pure ...))


From: Pietro Cerutti
Subject: Re: (declare (pure ...))
Date: Sat, 10 Feb 2024 09:20:49 +0000


On 10 Feb 2024, at 09:27, Al <frm.ml@mailgw.com> 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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]