[gambit-list] Bug (?) with BlackHole and append!

Marc Feeley feeley at iro.umontreal.ca
Fri Aug 6 13:09:28 EDT 2010


This is not a problem with blackhole.  Your program contains an error because it is trying to mutate a constant.  In Scheme, quoted objects are not mutable and it is an error to mutate them.  The interpreter does not enforce this error because it implements constants using mutable objects.  The compiler implements constants using "permanent objects" which cannot be mutated (they are not scanned by the garbage collector).

You could fix your program by doing

(define a (list 3 2 4 2))

instead of

(define a '(3 2 4 2))

Marc

On 2010-08-06, at 9:26 AM, Yves Parès wrote:

> Hello,
> 
> I have a file "test.scm" containing the following lines:
> 
> (import (std srfi/1))
> 
> (define a '(3 2 4 2))
> (append! a '(8 8 8))
> 
> (display a)
> (newline)
> 
> 
> When I lauch: gsc -e '(load "~~/lib/modules/build")' -
> and then (import test) it displays '(3 2 4 2 8 8 8)', which is fine.
> But if 'test' has been compiled first with (module-compile! 'test), then when importing I got the error:
> 
> *** ERROR IN ##main -- (Argument 1) MUTABLE object expected
> (set-cdr! '(2) '(8 8 8))
> 
> 
> (I use the last git version of BH)
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list



More information about the Gambit-list mailing list