Re: (declare (pure ...))

2024-02-10 Thread Pietro Cerutti
L > On 10 Feb 2024, at 13:30, Peter Bex wrote: > > On Sat, Feb 10, 2024 at 12:24:36PM +, Pietro Cerutti wrote: >> This is not how I reason about referential transparency. It is a property of >> functions applied to values, not variables. >> The fact that you can define x to different

Re: (declare (pure ...))

2024-02-10 Thread Al
On 2024-02-10 14:28, Peter Bex wrote: CHICKEN's type system differentiates between "pure" and "clean". A "pure" Hope this clears things up a bit! Ah, that's what I was looking for. So I shouldn't declare procedures using vector-ref as pure, but as clean. Now how do I declare a scheme

Re: (declare (pure ...))

2024-02-10 Thread Peter Bex
On Sat, Feb 10, 2024 at 12:24:36PM +, Pietro Cerutti wrote: > This is not how I reason about referential transparency. It is a property of > functions applied to values, not variables. > The fact that you can define x to different values or even rebind it in the > scope of a let binding

Re: (declare (pure ...))

2024-02-10 Thread Peter Bex
On Sat, Feb 10, 2024 at 11:12:04AM +, siiky via wrote: > Hi Al, > > > 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 > >

Re: (declare (pure ...))

2024-02-10 Thread Pietro Cerutti
> On 10 Feb 2024, at 11:10, Al wrote: > > On 2024-02-10 11:53, Pietro Cerutti wrote: > >> I don't see why vector-ref would be any less pure than, say, a let binding. >> Or do you mean vector-set! ? >> > vector-ref, applied to a global, could return different values even when > called with

Re: (declare (pure ...))

2024-02-10 Thread Pietro Cerutti
> On 10 Feb 2024, at 11:10, Al wrote: > > On 2024-02-10 11:53, Pietro Cerutti wrote: > >> I don't see why vector-ref would be any less pure than, say, a let binding. >> Or do you mean vector-set! ? >> > vector-ref, applied to a global, could return different values even when > called with

Re: (declare (pure ...))

2024-02-10 Thread siiky via
Hi Al, 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

Re: (declare (pure ...))

2024-02-10 Thread Al
On 2024-02-10 11:53, Pietro Cerutti wrote: I don't see why vector-ref would be any less pure than, say, a let binding. Or do you mean vector-set! ? vector-ref, applied to a global, could return different values even when called with the same arguments. Between calls, some other code could

Re: (declare (pure ...))

2024-02-10 Thread Pietro Cerutti
> On 10 Feb 2024, at 10:45, Al 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

Re: (declare (pure ...))

2024-02-10 Thread Pietro Cerutti
> On 9 Feb 2024, at 21:06, Al wrote: > Hi, > > > what does (declare (pure ..)) mean to csc? Is the function supposed to be > > * only side-effect free, or ... > > * also return the same value when called with the same arguments? Back to your original question

Re: (declare (pure ...))

2024-02-10 Thread Al
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

Re: (declare (pure ...))

2024-02-10 Thread Pietro Cerutti
> On 10 Feb 2024, at 09:27, Al 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

Re: (declare (pure ...))

2024-02-10 Thread Al
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

Re: (declare (pure ...))

2024-02-10 Thread Pietro Cerutti
> On 10 Feb 2024, at 09:06, Al 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

Re: (declare (pure ...))

2024-02-10 Thread Al
* 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,

Re: (declare (pure ...))

2024-02-09 Thread Pietro Cerutti
> On 9 Feb 2024, at 21:06, Al wrote: > > Hi, > > > what does (declare (pure ..)) mean to csc? Is the function supposed to be > > * only side-effect free, or ... > > * also return the same value when called with the same arguments? The first implies the sec

Re: (declare (pure ...))

2024-02-09 Thread siiky via
Hi Al, what does (declare (pure ..)) mean to csc? Is the function supposed to be * only side-effect free, or ... * also return the same value when called with the same arguments? I can't remember where `(declare)` is documented, but I believe this [0] is also relevant. [0] https

(declare (pure ...))

2024-02-09 Thread Al
Hi, what does (declare (pure ..)) mean to csc? Is the function supposed to be * only side-effect free, or ... * also return the same value when called with the same arguments? Thanks, Al