[plt-scheme] [ADT] : Modules or Units ?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Nov 18 10:37:04 EST 2002

At Mon, 18 Nov 2002 15:58:20 +0100, Jean-Paul Roy wrote:
> Can somebody from PLT elaborate on the pragmatic distinction
> between units and modules ? 

For a start, see the last section of "How to Use Modules":

  http://www.htus.org/Book/Staging/how-to-use-modules/

Summary:

Use a unit when code will be used in multiple contexts --- i.e., when
the imports can be satisified usefully in more than one way. This is
the main reason that we keep units in the language, in addition to
modules.

Another reason to use a unit is to have separate compilation with
mutual dependencies. Module imports form a DAG, while unit linking can
form an arbitrary graph.

Finally, I use units sometimes when I need to encapsulate state and
have multiple instances of the state. As you point out, a class can do
that, too.

[Side note for those interested in units: Expect a re-design of the
unit forms in the very near future.]

> And their links with teachpacks.

A teachpack is a module. (In 103, a teachpack was a unit, but
that'smainly because we had no modules.)

Matthew



Posted on the users mailing list.