[iterate-devel] bug and fix, multiple nil tags in tagbody
Hoehle, Joerg-Cyril
Joerg-Cyril.Hoehle at t-systems.com
Tue Oct 31 13:40:14 UTC 2006
Henrik Hjelte wrote:
>The Allegro compiler won't compile some iterate forms that expand to a
>tagbody form that has several nil tags.
Probably Allegro would complain the same about any two EQL tags in the
body.
You're right, that's a bug in Iterate. Actually, it's two bugs, and you
fixed only one of them ;)
1. Iterate must protect the TAGBODY it generates against inadvertent
tags. Probably, only NIL is problematic as a result of macroexpansion.
You found and correctly fixed this one.
That's why some people recommend against having macros ever expand to
NIL.
2. The code walker for TAGBODY is incorrect.
CLHS says: "The determination of which elements of the body are tags and
which are statements is made prior to any macro expansion of that
element. If a statement is a macro form and its macro expansion is an
atom, that atom is treated as a statement, not a tag."
Iterates macroexpands everything without that distinction. As a result
(macrolet ((foo () nil))
(iterate (repeat 1) (tagbody (foo) (foo))))
is not expanded correctly, and Allegro would complain.
The situation could be worse from the presence of macros with implicit
tagbodies, such as DO and PROG etc. Luckily, Iterate does not
special-case them, and relies on the implementation to provide correct
macro expanders eventually based on special forms. A nice example of
good tower construction (cf. "growing a language"). Of course, the
TAGBODY special form need be handled correctly.
Thank you for your bug report.
Regards,
Jorg Hohle.
More information about the iterate-devel
mailing list