Re: "cannot coerce inexact literal to fixnum"

2024-02-10 Thread Peter Bex
On Sat, Feb 10, 2024 at 04:07:12PM +0200, Al wrote: > On 2024-02-10 15:38, Peter Bex wrote: > > > That's because you're using fixnum mode. As I explained, using literals > > that might be too large for fixnums break the fixnum mode's premise that > > everything must be a fixnum. > > Oh. So it

Re: "cannot coerce inexact literal to fixnum"

2024-02-10 Thread Al
On 2024-02-10 15:38, Peter Bex wrote: That's because you're using fixnum mode. As I explained, using literals that might be too large for fixnums break the fixnum mode's premise that everything must be a fixnum. Oh. So it refuses to emit C code that might break on 32-bit at runtime (silent

Re: "cannot coerce inexact literal to fixnum"

2024-02-10 Thread Peter Bex
On Sat, Feb 10, 2024 at 02:32:16PM +0200, Al wrote: > That would be fine but where does that happen? csc actually barfs on my > Scheme code (as per the subject line), instead of emitting C code to > encode/decode into a string at runtime, as you mention. That's because you're using fixnum mode.

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: "cannot coerce inexact literal to fixnum"

2024-02-10 Thread Al
On 2024-02-10 13:00, Peter Bex wrote: These so-called "big-fixnums" are compiled into a string literal which gets decoded on-the-fly at runtime into either a fixnum (on 64-bit) or a bignum (on 32-bit). That would be fine but where does that happen? csc actually barfs on my Scheme code (as

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: "cannot coerce inexact literal to fixnum"

2024-02-10 Thread Peter Bex
On Sat, Feb 10, 2024 at 08:12:38AM +0200, Al wrote: > On 2024-02-10 02:42, Al wrote: > > > ... if I enable fixnum, csc chokes on both the third and fourth > > display's with: "Error: cannot coerce inexact literal `2147483647' to > > fixnum". It compiles and runs fine if those lines are commented

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, to make sure I understand:

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,