[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Attempt to modify read-only data



William Barry <barryw@ucs.orst.edu> is having trouble with the following
program file:

> (in-package 'user)
> (defvar temp-string "Matson, I need you")
> (setf (char temp-string 0) #\W)
> (print temp-string)

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
                    haible@ma2s2.mathematik.uni-karlsruhe.de