% -*- Mode:TeX -*-

\section{Background}
\label{background}

Nikhil in \cite{Nikhil85} pointed out the disparity between the
goals of an incremental programming environment, and
ML-like type inference system. ML \cite{SML-NJ89,Milner90} is
interactive, but a session in ML is essentially a large lexically nested
ML program. Each toplevel definition has the rest of the session as its
scope. Thus, editing an earlier definition may force the user to recompile
and reload all the intermediate definitions that used
it\footnote{SML's module mechanism gives some relief in this
respect, due to separate compilation.}. In building
large systems, the recompilation and reloading of large pieces of potentially
unrelated code, just to recreate the same environment every time a small
error is detected, is at best, quite annoying.

In Miranda \cite{Turner85,Turner86}, this problem is resolved by making the
unit of compilation to be a whole file (also called a ``Miranda script'').
Definitions within a file may appear in any order and the compiler is
responsible for reordering them during compilation.  The interactive
session only evaluates expressions using definitions from the current
script. But, definition level incrementality has been lost, and editing
forces entire files to be recompiled.

In contrast, Lisp programming environments smoothly integrate the
editor, the compiler, and the read-evaluate-print loop. The unit of
compilation in these systems is a single top-level definition. They
allow the user to furnish multiple top-level definitions, either
together, or one by one in any order, resolving global references to
other definitions automatically by dynamic linking.  The user can
test, debug, and edit these definitions incrementally, without waiting
to write the complete program or having to recompile a substantial fraction
of the definitions already supplied.

In Id, we attempt to achieve the flexibility of Lisp-like environments
along with static type-checking.  The programming environment for Id,
called ``Id World''\cite{Idworld}, smoothly integrates the editor, the Id
compiler, and the underlying execution vehicle. Like Lisp, our unit of
compilation is a single top-level definition. Each compiled definition is
accumulated into a flat global environment, implying that edited
definitions are immediately and automatically made available to other
definitions that use them.  Simple interprocedural book-keeping maintains
type-consistency between the definition and the uses of each top-level
identifier.  The book-keeping mechanism derives flexibility from the
polymorphism of the definitions, flagging only inconsistent definitions for
recompilation. As a consequence, we permit out of order compilation,
redefinition, and editing with minimum overhead, while still guaranteeing
type correctness before program execution.  We also allow executing
partially defined Id programs, where the undefined identifiers simply
generate an exception if actually used at run-time.  Again, the incremental
book-keeping mechanism helps in incorporating the missing parts as
and when they become available with minimum overhead.
