[plt-scheme] Modules/Libraries in MZScheme and R6RS

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon May 12 08:04:11 EDT 2008

At Sun, 11 May 2008 21:26:35 +0100, Filipe Cabecinhas wrote:
> - How can I import SRFIs into an R6RS program/library? (import (srfi  
> 1)) doesn't work.

I have no good answer so far. It works to write

  (import (srfi \x31;))

but that's crazy.

See also SRFI 97 and the discussion of whether `(srfi 1)' should be

> - Can I do something like (export (all-from-out <another-module>)) in  
> MzScheme's R6RS language? I couldn't find anything like that in the  
> standard so, maybe I have to name every single symbol to export.

R6RS offers nothing like `all-from-out'. You really have to name each

> - Speaking of export. Now we have forms like (provide (all-from- 
> out ...)), I know previously we had all-from and all-from-out in  
> require (I don't remember which one was the oldest, but I had some  
> files with those and now they broke), but now we have all-from in # 
> %require and all-from-out in require (by the documentation, it seems  
> all-from can't receive another spec, only a path). Will it be like  
> that from now on (require (*-in ...)) and (provide (*-out ...)), or  
> will we be able to do without the '-in/-out suffixes eventually? I  
> don't think they make it harder to understand because they just get in  
> the way. If it's a require, it's -in, if it's a provide, it's -out, no  
> need in having that in every form (unless there's something I'm  
> missing, of course).

In the old `require' form (which is now `#%require'), modifiers like
`all-from' were recognized symbolically. With the new `require',
`all-from-out' is a syntactic binding to a `require' transformer. This
change makes the `require' and `provide' forms macro-expandable. A
trade-off is that we have to manage the names more carefully, otherwise
we create lots of collisions in the namespace. The `-in' and `-out'
suffixes help avoid collisions.

See also


and the follow-up.

> - How can I refer to an MzScheme module/R6RS library like (require  
> "base.scm") in R6RS? If I have to have it in the collects dir, is  
> there any way I can add a directory to the collects' search path  
> through DrScheme? I suppose I can add a dir to the collects' search  
> path (if it's possible) and then do an (import (base)), am I correct?

Yes, something like that. The "Choose Language" dialog in DrScheme lets
you add paths to search for collections. But you won't be able to reach
"base.scm", exactly. The library reference `(base)' would mean the
"main.ss" (or "main.sls", etc.) file in the "base" collection, for
example. But that's the basic idea.

> P.S: In section 2.2 of the Guide ( http://docs.plt-
> scheme.org/reference/require.html#(form 
> ~20(~23~25kernel~20~23~25require)) ), you have a typo:



Posted on the users mailing list.