Hi Guilers, Find attached a very early, definitely broken first draft of R6RS library support. I was hoping to send this before / during Libre Planet '09, but AC outlets were scarce (and boozing at The Red Line so much easier than hacking) so I'm attempting to send this using the free WiFi on the Acela back to NYC. As discussed, this version uses the following approach for mapping Guile's module search / autoloading mechanism onto locating R6RS libraries: When a user or a library calls `import' with an import spec, 1. The import spec is unwrapped until an actual library reference is found. 2. If a matching library reference has already been loaded, an interface meeting the import spec's requirements is created and returned. 3. Otherwise, `resolve-interface' is called on the name portion of the library reference. If a satisficing interface cannot be loaded, the import fails. 4. Otherwise, the import system expects that either: a. The loaded Guile module has registered one or more versions of a corresponding R6RS library under the library name in the internal library registry via the `register-library' or `register-from-path' functions in `(ice-9 r6rs-libraries)'. If any versions of the library can be found in the registry, their versions are matched against the version in the library reference as per R6RS. b. The loaded Guile module is a non-R6RS Guile module (e.g., `(guile)' or `(ice-9 syncase)'). In this case, it is wrapped in an R6RS compatibility layer to make it accessible to the library system. What this means is that `(ice-9 r6rs-libraries)' can automatically load normal Guile modules, and that R6RS library expressions don't need to be modified in order to be loadable. It does require, however, that every installed set of versions of an R6RS library have a Guile module that serves as a catalog of sorts. This catalog module file might use `register-library' to register the entire library expression: (define-module (mystuff mylibrary) #:use-module (ice-9 r6rs-libraries)) (register-library '(library (mystuff mylibrary (1 2)) (export foo) (import (mystuff myotherlibrary)) (define (foo) (display "Hello, world!")))) ...or it could use the search path to register a library expression from an external file: (define-module (mystuff mylibrary) #:use-module (ice-9 r6rs-libraries)) (register-from-path "mystuff/mylibrary.scm.1") (register-from-path "mystuff/mylibrary.scm.1.2") This mechanism might need some tweaking, but I think it resolves some of the issues we were discussing earlier re: users installing R6RS libraries having to keep them separate from other Guile modules. If anyone's interested, I've created catalog modules and library expressions for the bits and pieces of the core set of R6RS libraries (including `(rnrs base)') necessary for testing, and I'd be happy to tar them up and make them available somewhere. Some other points: * This draft doesn't do any real validation of the `library' form. * Phased imports for the `define-syntax' form sort of work, but there are issues with cross-module visibility of bindings for symbols included in the output of transformers, as discussed here [1]. * Phased imports for the `letrec-syntax' and `let-syntax' forms don't work at all yet. Regards, Julian [1] - http://lists.gnu.org/archive/html/guile-user/2009-03/msg00015.html