Module Initialization and Ordering - Another Module Question

Presuming for now that a "module" 1) is a named and managed name space; 2) is a body of definitions, some of which are private and others provided for export to other modules; 3) is also a compilation unit; 4) is, in fact, imported by other modules, with circularity of imports forbidden or permitted based on the language definition; 5) is compiled separately and linked into a standalone "executable program" file; 6) may be a privileged module in an "executable program" linking activity as the "main" module containing either a function that begins program execution or a series of sequential definitions (or "statements") that essentially comprise an equivalent "main" function that begins program execution.

I think that's all grammatical, and in fact, more or less common policy for many programming languages with oodles of variations on this basic theme.

I seek papers that discuss (1) module initialization, such as a variable definition in a module that requires on it's "right hand side" a complex computation, 2) perhaps a computation that requires definitions from other modules, 3) the compile time determination of the "loading" or "initialization" of modules, 4) the wisdom or lack thereof of only allowing function definitions in modules, perhaps with only a special "initialization" section of the module definition (Modula 2, Turbo Pascal...); 5) policies regarding the permission or forbidding of circular module imports.

So I'm looking for the "finest available wisdom" about some fairly prosaic issues surrounding a few aspects - modules, initialization, ordering, separate compilation, etc. - of programming languages designed for static analysis and program compilation. Did anyone "get it just right?" Or has anyone layed out the essential and unavoidable design trade offs showing that "getting it right" is a matter of programming language design 1) taste or 2) intended purpose or 3) implementation complexity or 4) etc. - you get the idea.

I do prefer papers a *little* "closer to the run time," as it were. I happen to suffer the somewhat common "too many pages of Greek symbols shuts down my brain" syndrome :-)

Any and all help and pointers greatly appreciated.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Not really research papers,

Not really research papers, but I would look at the Ada model (specifically the history and thinking behind the pragmas Pure, Preelaborate, Elaborate, and Elaborate_Body). You can start here, here, and here.

Almost all of my favorite papers on module systems are here and here. Schemers have produced a lot of papers on this subject which are thought-provoking, pragmatic, and not overly theoretical. It is the finest available wisdom that I'm aware of!


There's a great overview of the ML community's finest available wisdom (love that expression) in Advanced Module Systems: A Guide for the Perplexed. (Just posted on another thread by Andreas Rossberg.)

R6RS, OSGi and the NetBeans Module System

You may find Scheme's R6RS module/library system of interest, as well as SRFI 83. R6RS libraries are expanded in different phases.

For more programming-language agnostic information about module initialization and ordering I'd suggest:

  • The NetBeans Runtime Container has evolved during the years and fine-tuned for performance. No circular dependencies, by design, and lazy initialization of modules. Recent versions include Features By Demand (on demand module initialization).
  • OSGi related literature explaining module dependencies and lazy initialization.

The finest wisdom

The finest wisdom on this topic, at least if you want computation at compile-time (such as macros) is found in Matthew Flatt's paper "Composable and Compilable Macros", ICFP 2002. You might find the explanation here easier to follow.