[racket] Cycles when loading modules

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Tue Oct 26 12:46:04 EDT 2010

Joe,

Check out the "racket/unit" library of dynamic, recursively-linkable
components.  You can define separate signatures for constraints and
connectors, then define a unit implementing each that imports one
signature and exports the other, and finally link the two modules
together.  The unit system will resolve the appropriate recursion.
You can then put each of these pieces in a separate module (file) if
you like; the implementation units only depend on the interfaces, and
only the linked unit depends on both implementations, so the modules
will not be cyclic even though the units are.

Carl Eastlund

On Tue, Oct 26, 2010 at 10:56 AM, Joe Snikeris <joe at snikeris.com> wrote:
> Hi all,
>
> I've encountered:
>
> standard-module-name-resolver: cycle in loading at...
>
> I understand the issue; however, I'm not sure how to resolve it while
> maintaining good design.  Perhaps my idea of good design is flawed.
> Anyway, I'm working on a problem from SICP [1] that involves several
> objects: primitive constraints (such as adders, multipliers,
> constants) and connectors (which connect primitive-constraints
> together).
>
> I have the primitive constraint procedures defined in one file, and
> the connector procedures in another.  The connectors use procedures
> that operate on primitive constraints and the primitive-constraints
> use procedures that operate on connectors.
>
> So there is a need to require the definitions for connectors in the
> primitive constraint file, and vice versa.
>
> For example, the connectors call a procedure (inform-about-value
> constraint) that I've defined in the primitive constraint file, since
> it operates on constraints.
>
> Any advice?
>
> Thanks in advance,
> Joe
>
> [1] - http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-22.html#%_thm_3.33\


Posted on the users mailing list.