separate compilation [was Re: Global variables?]

Andrew J Bromage ajb@spamcop.net
Thu, 6 Feb 2003 11:42:21 +1100


G'day all.

On Wed, Feb 05, 2003 at 04:16:33PM -0800, Iavor S. Diatchki wrote:

> why do you think separate compilation is difficult to achieve in Haskell 
> 98?

Because of type inference over recursive module imports.  Determining
the type of a function may, in general, require inferring types from an
arbitrary number of other modules, and may require inference to occur
at the level of granularity of a clique in the import graph, rather than
at the level of a single module.

Requiring an implementation to perform static analysis a clique at a
time is not "separate compilation", because changing something which is
private to one module may in general require an unbounded number of
other modules to be recompiled, even if inter-module optimisation is
turned off.

> as simon pointed out, GHC does it and has been doing it for a long 
> time.

GHC does separate compilation by requiring the programmer to step
outside H98, by writing GHC-specific hi-boot files.  I agree that
GHC therefore supports separate compilation, but, as Fergus pointed
out, it does not support separate compilation within H98.

> dealing with mutually recusrive modules is i think a separate 
> issue.

Why is it a separate issue?

> even though GHC doesn't quite do it, it is certainly possible, 
> and not very difficult to do.  in fact we have it implemented in one of 
> the projects i am currently working on. hopefully one day GHC will also 
> dispense with the hi-boot files.

I would certainly like to see this, but it doesn't fix the concern
noted above, that changing something private to one module may cause
an arbitrary number of other modules to be recompiled.  That is not
"separate compilation" by any definition of the word "separate" that
I am aware of.

Cheers,
Andrew Bromage