[Iterate-devel] iterate on list bug?
Gábor Balázs
gabalz at gmail.com
Wed May 21 07:06:30 UTC 2014
hY,
I have a feeling this is a bug.
(defvar mylist '(:one :two :three))
(iter (for var on mylist)
(collect (car var) into result)
(finally (return (values result var))))
(:ONE :TWO :THREE)
(:THREE)
I think var should be empty at the end, so the result would match the
result of loop as
(loop for var on mylist
collect (car var) into result
finally (return (values result var)))
(:ONE :TWO :THREE)
NIL
The problem is caused by the end test code location.
The bold lines should appear in reverse order, I think.
(macroexpand-1 '(iter (for var on mylist)
(collect (car var) into result)
(finally (return (values result var)))))
(LET* ((#:LIST214 NIL)
(VAR NIL)
(RESULT NIL)
(#:END-POINTER215 NIL)
(#:TEMP216 NIL))
(BLOCK NIL
(TAGBODY
(PROGN (SETQ #:LIST214 MYLIST))
LOOP-TOP-NIL
(PROGN
* (IF (ATOM #:LIST214) (GO LOOP-END-NIL)) (SETQ VAR
#:LIST214)* (SETQ #:LIST214 (CDR #:LIST214))
(PROGN
(SETQ #:TEMP216 (LIST (CAR VAR)))
(SETQ #:END-POINTER215
(IF RESULT
(SETF (CDR #:END-POINTER215) #:TEMP216)
(SETQ RESULT #:TEMP216)))
RESULT))
(PROGN)
(GO LOOP-TOP-NIL)
LOOP-END-NIL
(PROGN (RETURN (VALUES RESULT VAR))))
NIL))
Best,
` bg`
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/iterate-devel/attachments/20140521/742d6e87/attachment.html>
More information about the iterate-devel
mailing list