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

A bug in the new ANSI loop macro



I have the following code:

	(loop for char across fmt
	      do
	      (incf skip)
	      (case char
		(#\@ (setf at t))
		(#\: (setf colon t)))
	      until (operatorp char)
	      finally (setf cmd char))

(I'm trying to write the (formatter) macro.)  The problem is that
clisp reports

	*** - EVAL: variable CHAR has no value

in the "finally" clause.  This works for the example

	 (for i from 1 to 10...

example from Steele.  The problem is that the macroexpansion puts
the finally clause in a different scope when using the "across"
syntax:

(MACROLET ((LOOP-FINISH NIL (SYSTEM::LOOP-FINISH-ERROR)))
  (BLOCK NIL
    (LET NIL
      (LET ((#:G530 FMT) (#:G531 0))
	   (MACROLET ((LOOP-FINISH NIL '(GO SYSTEM::END-LOOP)))
	     (TAGBODY SYSTEM::BEGIN-LOOP
		      (PROGN (WHEN (>= #:G531 (LENGTH #:G530)) (LOOP-FINISH)))
		      (LET ((CHAR (AREF #:G530 #:G531)))
			   (PROGN
			    (PROGN (INCF SKIP)
				   (CASE CHAR
					 (#\@ (SETF AT T))
					 (#\: (SETF COLON T))))
			    (WHEN (OPERATORP CHAR) (LOOP-FINISH))))
		      (PROGN (PSETQ #:G531 (1+ #:G531)))
		      (GO SYSTEM::BEGIN-LOOP)
		      SYSTEM::END-LOOP
		      (MACROLET
		       ((LOOP-FINISH NIL (SYSTEM::LOOP-FINISH-WARN) '(GO SYSTEM::END-LOOP)))
		       (PROGN (SETF CMD CHAR)))))))))

This is clearly beyond my current level of lisp programming.

- David