[plt-scheme] mutually required modules

From: John Clements (clements at brinckerhoff.org)
Date: Tue May 6 14:57:24 EDT 2003

On Tuesday, May 6, 2003, at 02:47  PM, David A. Herman wrote:

>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> In separating modules between interfaces and implementations, I 
> sometimes
> find that I'd like to offer a particular implementation as the default 
> for
> convenience, but the mutual reference between modules causes a cycle in
> the module resolver. Would it be best to define the one default
> implementation in the interface module to avoid the cycle, or to leave 
> out
> the default altogether? Or is there some way to allow mutually required
> modules?
>
> Here's the simplest example I could come up with: a sort function that
> requires a comparison function but chooses one by default from the set 
> of
> default implementations:

In general, this is a restriction of modules; you cannot make them 
circularly dependent.  However, in this case, I don't see why you can't 
just separate the module containing the definition of the employee 
structure from the module defining the insert & sort operations.  
Alternatively, you can put them all in one module.  In the example you 
provide, I don't see why you've chosen the division that you have.

That's not to say that this problem doesn't come up, though.  There's a 
definite restriction on the ways modules can be assembled.

john



Posted on the users mailing list.