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

Different behaviors of evaluator and compiler

    Date: Wed, 21 Aug 91 12:25+0100
    From: Vincent Keunen <keunen@milou.nrb.be>


    This is a simple function to demonstrate the strange behaviour:
    (defun test ()
      (let ((result '(nil)))
	(loop for item in '(a b c)
	      do (nconc result (list item)))
    (test) ;when the function definition is evaluated returns
    (NIL A B C) ;...which is what I want
    (test) ;when the function definition is compiled returns
    1Error: Attempt to RPLACD a list that is embedded in a structure and
0           1therefore cannot be RPLACD'ed.  The list is (NIL)
0    While in the function SYS:RPLACD-ESCAPE  SYS:*NCONC  TEST
0       Arg 0 (CONS): (NIL)
       Arg 1 (SI:X): (A)
    s-A, :    Editor Top Level
    s-B:           Restart process Zmacs Windows
    Can someone help me on this one?
    Thank you
    Vincent Keunen
The error reported after the function is compiled has to do with the way
constants are stored in the COMPILED-FUNCTION object.  No doubt, someone
else will send you a more in-depth explanation of why that happens.

One solution is to rewrite the function TEST as such:
	(defun test ()
	  (loop for item in '(a b c)
		collect item))

Hope this helps.

		Craig Lanning <CLanning@PDESDS1.ATG.TRC.SCRA.ORG>