[plt-scheme] SRFI-7 broken in version 205

From: Bradd W. Szonye (bradd+plt at szonye.com)
Date: Fri Oct 17 14:18:28 EDT 2003

The implementation of SRFI-7 in PLT Scheme 205 has two serious bugs that
make the module unusable. The (feature-cond) clause doesn't actually
check for features, and the (requires) clause doesn't import modules
correctly. I've fixed the bugs and tested the fixes.

The (feature-cond) clause fails because a SYNTAX-CASE in program.ss is
missing "else" in the list of syntax literals. To fix this, apply the
following change to srfi/7/program.ss.

25c25
<       (syntax-case x (requires files code feature-cond and or not)
---
>       (syntax-case x (requires files code feature-cond and or not else)

The (requires) clause fails because the SRFI-7 macros put the module
names into the wrong namespace. When a macro uses (require spec), PLT
Scheme imports the module into the same namespace as "spec." The SRFI-7
module isn't careful enough about namespaces. To fix this, apply the
following changes to srfi/features.ss and srfi/7/program.ss.

srfi/features.ss:
29c29
<       (list (srfi-id->filename id) "srfi")
---
>       (cons 'lib (list (srfi-id->filename id) "srfi"))

srfi/7/program.ss:

15c15
<        (with-syntax ((clause
---
>        (with-syntax ((require-spec
17c17
<                        (syntax require)
---
>                        (syntax id)
21c21
<           (require (lib . clause))))))))
---
>           (require require-spec))))))

The change to features.ss generates a complete require spec for a SRFI.
For example, it returns (lib "7.ss" "srfi") instead of ("7.ss" "srfi").
The change to program.ss imports the module into the correct namespace
(the namespace of "id" instead of "require").

I have tested this change to make sure that it works in modules and in
the top-level namespace. My test suite is not comprehensive, so there
may be other bugs in SRFI-7. I'm working on a test suite to flush out
any other bugs.
-- 
Bradd W. Szonye
http://www.szonye.com/bradd


Posted on the users mailing list.