On 2024-02-10 11:20, Pietro Cerutti wrote:

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.

I agree. And if we step out of the monadic framework for just a bit, you'll see that there's room for an abstract machine in which purity just means "does not set! globals". This would still let the optimizer know that globals do not need to be re-checked after such a procedure is invoked, for example. I'm not sure if csc really uses the full "referentially transparent" definition (i.e. memoize-able), or just the "does not modify globals" one.


On a practical level, I would be sad if vector-ref, for example, was "impure", and thus compiling a vector-ref invalidated all previously-checked globals for the current scope. Likewise, I would prefer to declare a procedure using vector-ref as pure, to let csc know that it does not modify globals (or the filesystem etc).



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

I think that part just decides whether the procedure is "pure", for whatever purity means. That doesn't say anything about what compiling a call to such a "pure" procedure means (can memoize the value or not, need to re-check globals or closures afterwards or not etc).


-- Al


Reply via email to