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

Not sharp-sign dot, fools!



    Date: Wed, 11 Sep 85 23:34:13 EDT
    From: Kjeld Hvatum <KSH@MIT-MC.ARPA>
    To: common-lisp@SU-AI.ARPA
    Message-ID: <[MIT-MC.ARPA].642224.850911.KSH>

    From: Stephen E. Bacher
    To: Common LISP mailing list
    Re: Modifying constants in compiled code

     From Evan Kirshenbaum:

    > (defmacro compute-once (form)
    >   (let ((cell (cons nil nil)))
    >     `(if (car ',cell) (cdr ',cell)
    >          (progn
    >            (setf (car ',cell) t)
    >            (setf (cdr ',cell) ,form)))))
    >

     From Bernard S. Greenberg:

    > (defun switch ()
    >   (let ((y '#.(generate-cellx)))
    >     (prog1 (car y) (rplaca y t))))
    >
    > (defun generate-cellx () (cons nil nil))


    It seems to me that both of the above examples of self-modifying code
    that won't modify "read-only" structures are highly dependent upon the
    behavior of the compiler.  I generally expect the compiler, when it sees
    a form (QUOTE (mumble frotz)), to generate machine code to reference a
    LISP structure (mumble frotz) built in an area where constants are
    habitually placed, most likely a read-only area (if the implementation
    permits it).
King of sloppily typing fools, whose typos even work properly!
Thank you for paying attention!
I meant sharp-sign comma -of course-, where the compiler's
behavior is not an issue.  Now there's food for thought.