> On 10 Feb 2024, at 10:45, Al <frm...@mailgw.com> wrote: > > 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).
I don't see why vector-ref would be any less pure than, say, a let binding. Or do you mean vector-set! ? If the latter, well.. wouldn't your reasoning prevent you from using vector-set! on a global variable? -- 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.