If the <expression> is omitted from the "test"
clause of the "do" form, where you have
(<test> <expression> ...), then you get a
syntax error.
For example:
(do ((i 0 (+ i 1))) ((= i 5) ) (display (* i i)))
Here the exit test clause ((= i 5) ) has no
<expression> provided.
Below are the relevant data to test the bug and
a suggested change for the "do" special form.
Remarks: 1) first "do" works;
2) second "do" gets syntax error
3) first "define do" is present code
4) second "define do" is a suggested
change of using "cond" rather than "if"
Note: I am not at all sure that the second "define
do" is correct or not.
============================================
(do ((i 0 (+ i 1))) ((= i 5) 1000) (display (* i i)))
(do ((i 0 (+ i 1))) ((= i 5) ) (display (* i i)))
(define do
(macro (bindings test-and-result . body)
(let ((variables (map first bindings))
(inits (map second bindings))
(steps (map (lambda (clause)
(if (null? (cddr clause))
(first clause)
(third clause)))
bindings)))
`(letrec (([loop]
(lambda ,variables
(if ,(first test-and-result)
(begin . ,(rest test-and-result))
(begin
,@body
([loop] . ,steps))))))
([loop] . ,inits)))))
(define do
(macro (bindings test-and-result . body)
(let ((variables (map first bindings))
(inits (map second bindings))
(steps (map (lambda (clause)
(if (null? (cddr clause))
(first clause)
(third clause)))
bindings)))
`(letrec (([loop]
(lambda ,variables
(cond
(,(first test-and-result)
. ,(rest test-and-result))
(else (begin
,@body
([loop] . ,steps)))))))
([loop] . ,inits)))))
============================================
This problem arose when I was trying to install
the "slib" library.
-- Bill Hale
Logged In: YES
user_id=17797
This has been fixed in the current version (5.0)