Hi,
I just don't know what's wrong with the following loop example.
My understanding was the example should return X.
Am I missing something?
Thanks.
% lisp
CMU Common Lisp 18e, running on hinttika.msi.co.jp
With core: /usr/lib/cmucl/lib/lisp.core
Dumped on: Thu, 2003-04-03 22:47:12+09:00 on orion
See <http://www.cons.org/cmucl/> for support information.
Loaded subsystems:
Python 1.1, target Intel x86
CLOS 18e (based on PCL September 16 92 PCL (f))
* (loop for i in '(1 2 x 3) when (symbolp i) return i while (< i 3) collect i)
Argument X is not a REAL: X.
Restarts:
0: [ABORT] Return to Top-Level.
Debug (type H for help)
(KERNEL:TWO-ARG-< X 3)
Source: Error finding source:
Error in function DEBUG::GET-FILE-TOP-LEVEL-FORM: Source file no longer exists:
target:code/numbers.lisp.
0] :backtrace
0: (KERNEL:TWO-ARG-< X 3)
1: (< X 3)
2: ("Top-Level Form")[:TOP-LEVEL]
3: (INTERACTIVE-EVAL (LOOP FOR I IN '(1 2 X 3) ...))
4: (COMMON-LISP::%TOP-LEVEL)
5: (COMMON-LISP::RESTART-LISP)
0]
On 27 Aug 2003 18:17:12 +0900, KURODA Hisao <······@msi.co.jp> wrote:
> I just don't know what's wrong with the following loop example. My
> understanding was the example should return X. Am I missing
> something?
>
> Thanks.
>
> % lisp
> CMU Common Lisp 18e, running on hinttika.msi.co.jp
> With core: /usr/lib/cmucl/lib/lisp.core
> Dumped on: Thu, 2003-04-03 22:47:12+09:00 on orion
> See <http://www.cons.org/cmucl/> for support information.
> Loaded subsystems:
> Python 1.1, target Intel x86
> CLOS 18e (based on PCL September 16 92 PCL (f))
> * (loop for i in '(1 2 x 3) when (symbolp i) return i while (< i 3) collect i)
>
> Argument X is not a REAL: X.
(loop for i in '(1 2 x 3)
when (symbolp i) do (return i)
while (< i 3) collect i)
Edi.
Edi Weitz <···@agharta.de> writes:
> > * (loop for i in '(1 2 x 3) when (symbolp i) return i while (< i 3) collect i)
> > Argument X is not a REAL: X.
>
> (loop for i in '(1 2 x 3)
> when (symbolp i) do (return i)
> while (< i 3) collect i)
Yes, I knew this worked. But why my example fails?
KURODA Hisao wrote:
> Edi Weitz <···@agharta.de> writes:
>
>
>>>* (loop for i in '(1 2 x 3) when (symbolp i) return i while (< i 3) collect i)
>>>Argument X is not a REAL: X.
>>
>>(loop for i in '(1 2 x 3)
>> when (symbolp i) do (return i)
>> while (< i 3) collect i)
>
>
> Yes, I knew this worked. But why my example fails?
It's a bug.
Paul
KURODA Hisao <······@msi.co.jp> writes:
> Edi Weitz <···@agharta.de> writes:
>
>> > * (loop for i in '(1 2 x 3) when (symbolp i) return i while (< i 3) collect i)
>> > Argument X is not a REAL: X.
>>
>> (loop for i in '(1 2 x 3)
>> when (symbolp i) do (return i)
>> while (< i 3) collect i)
>
> Yes, I knew this worked. But why my example fails?
It's apparently a bug in cmucl's implementation of loop, perhaps based
on experimentation that was done around the time of standardization.
As near as I can make out from the comments in the source, this
behaviour was intended to allow for certain exceptional cases to be
easier to write. However, this is in violation of the standard, so
here's a patch for the problem:
(in-package "ANSI-LOOP")
(defun loop-pseudo-body (form)
(push form *loop-body*))
Christophe
--
http://www-jcsu.jesus.cam.ac.uk/~csr21/ +44 1223 510 299/+44 7729 383 757
(set-pprint-dispatch 'number (lambda (s o) (declare (special b)) (format s b)))
(defvar b "~&Just another Lisp hacker~%") (pprint #36rJesusCollegeCambridge)