Scheme48 fork update
Mike Sperber finally reviewed my patches; they unfortunatly were not deemed appropriate for the Scheme48 distribution, see this thread. Hopefully these issues can be sorted out in the not-to-far future. If you also need the one or other features from my hacks so far, and are adventurous, you can conact me on #scheme on freenode for help with getting and building my fork.
Writing portable Scheme programs with scmxlate and spells
For the conjure project, we are using scmxlate to make it portable across multiple Schemes. For that purpose, I slightly extended scmxlate and built a kind of meta-module system on top of it. Here is how that looks like:
You write a description of the modules your application or library is made of; this is done in a sightly extended subset of the Scheme48 configuration language. For example (from this page, see there for more details):
(define-structure conjure.foo.bar (export qux baz
((froboz fribnitz)
:syntax))
(open scheme srfi-1 srfi-13 conjure.util.files)
(dialect (guile (open ice-9.syncase))
(scheme48 (open extended-ports)))
(files (foo basic-bar)
(foo bar)))
This defines the module conjure.foo.bar, which exports the identifiers qux and baz, as well as the macros froboz and fribnitz. The open clause means: this module is written in R5RS Scheme (scheme), plus additionally using srfi-1, srfi-13 and the conjure.util.files module. The dialect clause can be used for specifiying additional modules needed for the dialect-specific code for the module. Finally, the files clause tells us that this module consists of the files foo/basic-bar.scm and foo/bar.scm.
This file then gets processed by scmxlate, generating a file with the right module definitions for the selected target dialect, e.g.:
(define-module (conjure foo bar)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-13)
#:use-module (conjure util files)
#:use-module (ice-9 syncase)
#:export (qux baz)
#:export-syntax (froboz fribnitz))
;; code for foo/basic-bar.scm and foo/bar.scm follows
will be generated for Guile.
We recently split scmxlate and the meta-module systeem out of conjure, see the scmxlate category in the conjure archive, so it is available for other projects. Now the split-out of the general purpose modules into a separate project -- SPELLS, (S)pell's a (P)ortability (E)nvironment (L)ibrary for (L)ots of (S)chemes -- is in preparation. This library will further aid writing portable code, by providing a consistent interface to functionality that has different APIs in different Schemes. These modules are already there:
- spells.util.pregexp: Dorai Sitaram's portable regular expressions
- spells.util.named-args: Conviniently create procedures with named arguments
- spells.util.table: Hash tables
- spells.util.condition: SRFI 34 and SRFI 35
- spells.system.file: Lots of file-related proedures, e.g. copy-file, directory?, ...
All of those are implemented for all of mzscheme, Guile, Scheme48 and Gauche, using native functionality where available. Other modules will surely follow, a project has been requested at Gna! to facilitate contribution. The spells library will also be used by my upcoming port of G-Wrap to Scheme48.