Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

execution order of loop [cmucl]

10 views
Skip to first unread message

KURODA Hisao

unread,
Aug 27, 2003, 5:17:12 AM8/27/03
to
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]

Edi Weitz

unread,
Aug 27, 2003, 5:35:20 AM8/27/03
to
On 27 Aug 2003 18:17:12 +0900, KURODA Hisao <kur...@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.

KURODA Hisao

unread,
Aug 27, 2003, 9:08:49 PM8/27/03
to
Edi Weitz <e...@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?

Paul F. Dietz

unread,
Aug 27, 2003, 9:32:54 PM8/27/03
to

It's a bug.

Paul

Christophe Rhodes

unread,
Aug 28, 2003, 6:38:46 AM8/28/03
to
KURODA Hisao <kur...@msi.co.jp> writes:

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)

0 new messages