[iterate-devel] bug and fix, multiple nil tags in tagbody
Henrik Hjelte
henrik at evahjelte.com
Wed Oct 25 16:26:27 UTC 2006
The Allegro compiler won't compile some iterate forms that expand to a
tagbody form that has several nil tags. At first I thought that it was a
bug with allegro, since it worked fine in sbcl, and in allegros own
interpreter. But on second thought and some reading of the hyperspec, I
think it is the allegro compiler that is right:
hyperspec:
...The statements in a tagbody are evaluated in order from left to
right, and their values are discarded. If at any time there are no
remaining statements, tagbody returns nil. However, if (go tag) is
evaluated, control jumps to the part of the body labeled with the tag.
(Tags are compared with eql.) ...
and since tags are compared with eql, how can we allow several nils? If
tags with the same label was allowed, the description should say
something about "the first" or "the last" tag. Now it says labeled with
THE tag, singularis.
I have attached two bundled darcs-patches, first a testcase that shows
the problem, then a solution. I have run all tests with sbcl and
allegro. As usual it turns out it was more difficult to write a test
than to fix the bug.
/Henrik Hjelte
(TAGBODY
(print "hi")
NIL
(print "ciao")
LOOP-TOP-NIL
(print "hello")
NIL
(print "second nil")
)
; the Allegro error is :
;;Tag NIL is used more than once
;;Problem detected when processing
;; (TAGBODY (PRINT "hi") NIL...)
;;inside (BLOCK MYTEST (TAGBODY (PRINT "hi") NIL...))
;;inside (PROGN (BLOCK MYTEST (TAGBODY # NIL...)))
;;
;; [Condition of type PARSE-ERROR]
And why these nils turn up in iterate, see the testcase in the patch for
an example.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tagbodynil.patch
Type: text/x-patch
Size: 2266 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/iterate-devel/attachments/20061025/3f6fb976/attachment.bin>
More information about the iterate-devel
mailing list