~ubuntu-branches/ubuntu/karmic/ocaml-doc/karmic

« back to all changes in this revision

Viewing changes to ocaml.html/manual020.html

  • Committer: Bazaar Package Importer
  • Author(s): Vanicat Rémi
  • Date: 2002-02-05 10:51:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020205105143-a061tunf8tev07ne
Tags: 3.04-4
* New debian maintainer
* Split doc-base file
* Move to non-free
* Change the copyright file to the copyright of the documentation
* remove FAQs (their license prohibit their redistribution)
* corrected the examples

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
 
2
            "http://www.w3.org/TR/REC-html40/loose.dtd">
 
3
<HTML>
 
4
<HEAD>
 
5
 
 
6
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 
7
<META name="GENERATOR" content="hevea 1.06-7 of 2001-11-14">
 
8
<TITLE>
 
9
 Compilation units
 
10
</TITLE>
 
11
</HEAD>
 
12
<BODY TEXT=black BGCOLOR=white>
 
13
<A HREF="manual019.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
 
14
<A HREF="manual008.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
 
15
<HR>
 
16
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
 
17
<TR><TD BGCOLOR="#66ff66"><DIV ALIGN=center><TABLE>
 
18
<TR><TD><A NAME="htoc88"><B><FONT SIZE=5>6.12</FONT></B></A></TD>
 
19
<TD WIDTH="100%" ALIGN=center><B><FONT SIZE=5>Compilation units</FONT></B></TD>
 
20
</TR></TABLE></DIV></TD>
 
21
</TR></TABLE>
 
22
<BR>
 
23
<DIV ALIGN=center><TABLE CELLSPACING=2 CELLPADDING=0>
 
24
<TR><TD ALIGN=right NOWRAP>
 
25
<TT><I><FONT COLOR=maroon>unit-interface</FONT></I></TT></TD>
 
26
<TD ALIGN=right NOWRAP>::=</TD>
 
27
<TD ALIGN=left NOWRAP> { <TT><I><FONT COLOR=maroon>specification</FONT></I></TT> &nbsp;[<TT><FONT COLOR=blue>;;</FONT></TT>] }</TD>
 
28
</TR>
 
29
<TR><TD ALIGN=right NOWRAP>
 
30
<TT><I><FONT COLOR=maroon>unit-implementation</FONT></I></TT></TD>
 
31
<TD ALIGN=right NOWRAP>::=</TD>
 
32
<TD ALIGN=left NOWRAP> { <TT><I><FONT COLOR=maroon>definition</FONT></I></TT> &nbsp;[<TT><FONT COLOR=blue>;;</FONT></TT>] }</TD>
 
33
</TR></TABLE></DIV><BR>
 
34
Compilation units bridge the module system and the separate
 
35
compilation system. A compilation unit is composed of two parts: an
 
36
interface and an implementation. The interface contains a sequence of
 
37
specifications, just as the inside of a <TT><FONT COLOR=blue>sig</FONT></TT> ... <TT><FONT COLOR=blue>end</FONT></TT>
 
38
signature expression. The implementation contains a sequence of
 
39
definitions, just as the inside of a <TT><FONT COLOR=blue>struct</FONT></TT> ... <TT><FONT COLOR=blue>end</FONT></TT> module
 
40
expression. A compilation unit also has a name <TT><I><FONT COLOR=maroon>unit-name</FONT></I></TT>, derived
 
41
from the names of the files containing the interface and the
 
42
implementation (see chapter&nbsp;<A HREF="manual022.html#c:camlc">8</A> for more details). A
 
43
compilation unit behaves roughly as the module definition
 
44
<DIV ALIGN=center>
 
45
<TT><FONT COLOR=blue>module</FONT></TT> <TT><I><FONT COLOR=maroon>unit-name</FONT></I></TT> <TT><FONT COLOR=blue>:</FONT></TT> <TT><FONT COLOR=blue>sig</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>unit-interface</FONT></I></TT> <TT><FONT COLOR=blue>end</FONT></TT> <TT><FONT COLOR=blue>=</FONT></TT>
 
46
 <TT><FONT COLOR=blue>struct</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>unit-implementation</FONT></I></TT> <TT><FONT COLOR=blue>end</FONT></TT>
 
47
</DIV><BR>
 
48
A compilation unit can refer to other compilation units by their
 
49
names, as if they were regular modules. For instance, if <TT>U</TT> is a
 
50
compilation unit that defines a type <TT>t</TT>, other compilation units can
 
51
refer to that type under the name <TT>U.t</TT>; they can also refer to <TT>U</TT> as
 
52
a whole structure. Except for names of other compilation units, a unit
 
53
interface or unit implementation must not have any other free variables.
 
54
In other terms, the type-checking and compilation of an interface or
 
55
implementation proceeds in the initial environment
 
56
<DIV ALIGN=center>
 
57
<TT><I><FONT COLOR=maroon>name</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>:</FONT></TT> <TT><FONT COLOR=blue>sig</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>interface</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> <TT><FONT COLOR=blue>end</FONT></TT> ...
 
58
 &nbsp;<TT><I><FONT COLOR=maroon>name</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> <TT><FONT COLOR=blue>:</FONT></TT> <TT><FONT COLOR=blue>sig</FONT></TT> &nbsp;<TT><I><FONT COLOR=maroon>interface</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> <TT><FONT COLOR=blue>end</FONT></TT>
 
59
</DIV>
 
60
where <TT><I><FONT COLOR=maroon>name</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> ... &nbsp;<TT><I><FONT COLOR=maroon>name</FONT></I></TT><SUB><FONT SIZE=2><I>N</I></FONT></SUB> are the names of the other
 
61
compilation units available in the search path (see
 
62
chapter&nbsp;<A HREF="manual022.html#c:camlc">8</A> for more details) and <TT><I><FONT COLOR=maroon>interface</FONT></I></TT><SUB><FONT SIZE=2>1</FONT></SUB> ...
 
63
&nbsp;<TT><I><FONT COLOR=maroon>interface</FONT></I></TT><SUB><FONT SIZE=2><I>n</I></FONT></SUB> are their respective interfaces.
 
64
 
 
65
<HR>
 
66
<A HREF="manual019.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
 
67
<A HREF="manual008.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
 
68
</BODY>
 
69
</HTML>