[plt-scheme] mutually-recursive modules
Noel Welsh writes:
> --- Doug Orleans <dougo at place.org> wrote:
>
> > So, module B requires module A, but module A needs
> > to refer to a
> > procedure P defined in module B. This trick seems
> > to work:
>
> Seems like a maintenance nightmare. If P logically
> belongs in B but is defined in A...I wouldn't want to
> maintain the code. Is there a true cycle or is it
> just B and A depend on P but not vice versa? If the
> later, you should put P into a separate module. If
> the former I'd use a unit.
It's a true cycle: P depends on module A. Moreover, it depends on
modules C, D, and E, all of which also depend on module A. If I
wrapped the definitions in A in a unit, and invoked the unit in module
B (where P is defined), I think I'd also have to wrap everything in C,
D, and E in units, so that they could be invoked in B also. There's
only one single back-pointer, and this seems like a simpler solution
than converting everything to units (or putting everything into one
module).
--dougo at place.org