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

Re: A bug in the new ANSI loop macro



   Date: Wed, 12 Apr 95 15:07:12 +0200
   From: "David J. Fiander" <davidf@mks.com>

A close reading of X3J13-94-101 and the issue history indicates that
clisp is correct, at least insofar as the standard is purposefully
vague on the issue.  The only LOOP bindings available in FINALLY
clauses are ones created by WITH clauses (and, by extension, INTO
phrases).  It is left unspecified whether bindings created with FOR or
AS clauses are available.  In most Common Lisps I am familiar with,
they are, but clisp is justified by the standard in not having them be
available.

This issue was discussed at length on the X3J13 mailing list as
LOOP-FOR-AS-VARIABLE-TERMINATION-VALUE.  I don't have my archives
handy, but I recall that the debate centered on problems with
arithmetic values being stepped past their ranges.

To get around the problem, you'd have to do something like:

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

Ugly, but those are the breaks.

   (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.

X3J13 "solved" the problem by changing the examples in the standard
that have FOR/AS bound variables referred to in FINALLY clauses so that
they didn't anymore.

Great title for a course:  "Programming as Archaeology."

--David Gadbois