set-car! and set-cdr! throw vm-exception on lists defined with quotation

Andrew Stok <[email protected]> Sun, 4 Apr 2010 21:15:31 +0000 (UTC)
Newsgroups gmane.lisp.scheme.scheme48
Message-ID <[email protected]>
Hi,

I'm relatively new to scheme, so I apologize if this is not actually a bug.

I'm running Scheme 48 1.8.

First, as a sanity check use set-car! on a list defined using "list"
procedure...

> (define z1 (list 4))
; no values returned
> (car z1)
4
> (cdr z1)
'()
> (set-car! z1 5)
#{Unspecific}
> (car z1)
5
> (cdr z1)
'()

In this case, everything works fine.

----------------------------------------------------------
Now, perform the same operations, but this time define the list using
quotation...

> (define z2 '(4))
; no values returned
> (car z2)
4
> (cdr z2)
'()
> (set-car! z2 5)

Error: vm-exception
       (set-car! '(4) 5)

This result was unexpected.  The only difference between the two lists
is the method in which they were defined.  set-cdr! exhibits the same
behavior.

Thanks,

Andrew