[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>
Subject: Different behaviors of evaluator and compiler
To: SLUG@AI.SRI.COM
Message-ID: <19910821112550.5.KEUNEN@milou.nrb.be>
Character-Type-Mappings: (1 0 (NIL 0) (NIL :ROMAN NIL) "CPTFONT")
(2 0 (NIL 0) (:FIX :BOLD :NORMAL) "CPTFONTCB")
Fonts: CPTFONT, CPTFONT, CPTFONTCB
I came across something I don't understand the reasons... Can someone
explain why this is so and how to solve this problem? Thank you.
What I want to do:
I want to make a list of items. There are lots of them, so I figured
out that I might as well nconc instead of appending to limit the number
of conses (I don't know the items in advance; they are produced by a
loop). Therefore, I accumulate everything in "result". If I initialize
result with the empty list ('() or nil), I get an error because I can't
nconc that, which I understand. So I initialize it with '(nil) because
I don't mind having something at the start of the list (initializing it
with '(anything) gives the same behaviour).
This is a simple function to demonstrate the strange behaviour:
1(defun test ()
(let ((result '(nil)))
(loop for item in '(a b c)
do (nconc result (list item)))
result))
(test)0 ;when the function definition is evaluated returns
1(NIL A B C)0 ;...which is what I want
1(test)0 ;when the function definition is compiled returns
2Error: Attempt to RPLACD a list that is embedded in a structure and
0 2therefore cannot be RPLACD'ed. The list is (NIL)
0While in the function SYS:RPLACD-ESCAPE SYS:*NCONC TEST
2SYS:RPLACD-ESCAPE
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
keunen@nrb.be