[comp.sys.xerox] Undocumented i.s. feature

TANNER-M%osu-20@OHIO-STATE.ARPA (Mike Tanner) (12/31/87)

I ran into this in Koto but it also happens in Lyric Interlisp.

The following iterative statement --

	(for i from x to y by z do (foo))

translates (i.e., DWIMIFY's) to --

	(PROG (($$TEM2 y) $$TEM1 $$VAL (i x))
	  $$LP
	      (COND ((AND $$TEM1 (OR (ZEROP $$TEM1)
				     (COND ((MINUSP $$TEM1) (LESSP i y))
					   (T (GREATERP i y)))))
		     (RETURN $$VAL)))
	      (foo)
	  $$ITERATE
	      (SETQ i (PLUS i (SETQ $$TEM1 z)))
	      (GO $$LP))

The problem is that it locally binds the temporary variable $$TEM2 to the
value of y, as the Interlisp manual says it should, but then in the
termination check it uses y.  I.e., contrary to the manual's description 
(pg. 9.14) of "TO FORM":
	"Note:  FORM is evaluated only once, when the i.s. is first entered,
	and its value bound to a temporary variable against which the i.v. is
	checked each iteration."

If you take out the "by" --

	(for i from x to y do (foo))

it DWIMIFY's correctly, i.e. --

	(PROG (($$TEM1 y) $$VAL (i x))
	  $$LP
	      (COND ((GREATERP i $$TEM1)))))
		     (RETURN $$VAL)))
	      (foo)
	  $$ITERATE
	      (SETQ i (PLUS i 1))
	      (GO $$LP))


Looks like a bug to me.

-- mike

tanner@tut.cis.ohio-state.edu
-------