Subject: Attempt to modify read-only data

From: William Barry <[email-masked]>
Date: Tue, 22 Nov 1994 11:01:58 -0800 (PST)

I am having trouble with the following test file using 
the 10-26-94 version of clisp under Linux 
-----test2.lisp-----------------
(in-package 'user)
(defvar temp-string "Matson, I need you")
(setf (char temp-string 0) #\W)
(print temp-string)
---------------------------------------------
I get the following output

> (load 'test2.lisp)
;; Loading file test2.lisp ...
*** - Attempt to modify read-only data
1. Break> up

EVAL frame for form (SETF (CHAR TEMP-STRING 0) #\W)
1. Break>
---------------------------------------------------
It works fine using the dos version of clisp.
Can anyone suggest a way of fixing this?
Thanks,
Bill Barry

---

From: haible (Bruno Haible)
Date: Fri, 25 Nov 94 02:35:00 +0100

William Barry <[email-masked]> is having trouble with the following

> (setf (char temp-string 0) #\W)

Common Lisp forbids to modify constants that appear in programs, because
this is the way a certain class of "self-modifying programs" works. Your
string is such a constant. If you intend to modify it, you have to copy it:

  (defvar temp-string (copy-seq "Matson, I need you"))

> It works fine using the dos version of clisp.

Because under Linux and some other Unices it is possible to catch this kind
of error at no speed cost, whereas under DOS it would make CLISP slower
so I refrained from implementing the check.

                    Bruno Haible
                    [email-masked]