[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Slib-discuss] Proper way to add one's own "impcat" to Slib
From: |
Aubrey Jaffer |
Subject: |
Re: [Slib-discuss] Proper way to add one's own "impcat" to Slib |
Date: |
Sat, 13 Dec 2008 00:39:26 -0500 (EST) |
| From: Kris De Volder <address@hidden>
| Date: Thu, 11 Dec 2008 21:44:44 -0800
|
| On Thu, 2008-12-11 at 18:26 -0500, Aubrey Jaffer wrote:
| ...
| > "mkimpcat.scm" should produce a file named "implcat". The CATCAT
| > procedure at the end of "slib/mklibcat.scm" copies "implcat" onto
| > the end of "slib/slibcat".
|
| ...
| But upon reading your explanation I went back and dug a bit deeper
| into what catcat was doing. As it turns out, my "do" macro was broken
| for this case:
|
| (do (<inits>)
| (<test-exp>)
| <body>)
|
| I.e. a do-loop which doesn't have a return value expression with
| the test-exp. It turns out that this case is not being covered by
| the r4rs test suite, and since I don't use do-loops myself, this
| bug slipped by unnoticed all this time.
|
| So, I propose to add the following two test cases to r4rstest.scm:
|
| (SECTION 4 2 4)
| ...
|
| (test 25 'do (let ((x '(1 3 5 7 9)))
| (do ((x x (cdr x))
| (sum 0 (+ sum (car x))))
| ((and (null? x) sum)))))
| (test 25 'do (let ((x '(1 3 5 7 9))
| (sum 0))
| (do ((x x (cdr x)))
| ((and (null? x) sum))
| (set! sum (+ sum (car x))))))
Both of your do expressions return an unspecified value according to
R4RS and R5RS:
-- library syntax: (do ((<variable1> <init1> <step1>) ...)
(<test> <expression> ...)
<command> ...)
....
If <test> evaluates to a true value, then the <expression>s are
evaluated from left to right and the value(s) of the last
<expression> is(are) returned. If no <expression>s are present,
then the value of the `do' expression is unspecified.
| Thanks again. I was really not looking at the right code until your
| message clarified how mklibcat was supposed to work.
I have added explanations to slib.texi.
The development version is updated:
http://groups.csail.mit.edu/mac/ftpdir/users/jaffer/slib.zip
Also, the CVS repository is updated:
https://savannah.gnu.org/cvs/?group=slib