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

Issue: CONSTANT-SIDE-EFFECTS (no proposal)



re: it is common practice to do things like

      (DEFVAR *X* '(A B C))
      (SETF (SECOND *X*) 'Z)

    Perhaps it would be better to say (DEFVAR *X* (COPY-LIST '(A B C))) but
    requiring that would invalidate a lot of existing code.  I don't think
    that this inconsistency is really a problem . . . 

How about:

      (DEFCONSTANT X '(A B C))
      (SETF (SECOND X) 'Z)

Is this inconsistency not really a problem either??


re: . . . Note that the
    object file loader knows that a value is only used as a constant before it
    creates it, so it can create it in the proper memory area, but READ does
    not have any such context information, so write-protecting constants in
    the interpreter or in-memory compilation means copying them.

Many people assume that the definition of QUOTE in (QUOTE <x>) must be simply 
to return the program fragment <x> exactly as read in by the reader.  I have 
an interpreter design in mind that does something else -- namely it "caches" 
an equivalent copy of <x>.  Except for symbols (and packages, and classes) 
the results of QUOTE would never be simply the s-expression that was read-in.
At least you only need one copy in the constant area (where equivalence
of copies is something more featureful than EQUAL).


-- JonL --