1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>The PolyML.NameSpace structure</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="docstyle.css" rel="stylesheet" type="text/css">
</head>
<body>
<ul class="nav">
<li><a href="PolyMLMake.html">Previous</a></li>
<li><a href="PolyMLStructure.html">Up</a></li>
<li><a href="#">Next</a></li>
</ul>
<H2><STRONG><font face="Arial, Helvetica, sans-serif">The PolyML.NameSpace structure</font></STRONG></H2>
<p> The <span class="identifier">PolyML.NameSpace</span> structure contains functions
associated with a name-space, a collection of values, types, structures, functors,
signatures and infix settings. It is used primarily in connection with the compiler.</p>
<p>In the Standard ML language there are separate classes of identifiers for values,
type constructors, structures, signatures and functors. In addition infix status
is essentially another identifier class since infix status and priority can
be set for an identifier whether or not there is actually a function with that
name. Value identifiers include datatype and exception constructors as well
as identifiers bound with <span class="identifier">val</span> or <span class="identifier">fun</span>
bindings. Name-spaces are ways of holding and managing collections of identifiers.
Nothing in the NameSpace structure assumes a particular implementation of a
name-space; it is more of an interface than an implementation.</p>
<pre class="mainsig">structure NameSpace:
sig
type <a href="#typeVal">typeVal</a>
type <a href="#valueVal">valueVal</a>
type <a href="#fixityVal">fixityVal</a>
type <a href="#functorVal">functorVal</a>
type <a href="#signatureVal">signatureVal</a>
type <a href="#structureVal">structureVal</a>
val displayVal: valueVal * int * nameSpace -> pretty
val displayType: typeVal * int * nameSpace -> pretty
val displayFix: string * fixityVal -> pretty
val displayFunct: functorVal * int * nameSpace -> pretty
val displaySig: signatureVal * int * nameSpace -> pretty
val displayStruct: structureVal * int * nameSpace -> pretty
val codeForFunct: functorVal -> CodeTree.codetree
val codeForStruct: structureVal -> CodeTree.codetree
val codeForValue: valueVal -> CodeTree.codetree
type <a href="#nameSpace">nameSpace</a> =
{allFix: unit -> (string * fixityVal) list,
allFunct: unit -> (string * functorVal) list,
allSig: unit -> (string * signatureVal) list,
allStruct: unit -> (string * structureVal) list,
allType: unit -> (string * typeVal) list,
allVal: unit -> (string * valueVal) list,
enterFix: string * fixityVal -> unit,
enterFunct: string * functorVal -> unit,
enterSig: string * signatureVal -> unit,
enterStruct: string * structureVal -> unit,
enterType: string * typeVal -> unit,
enterVal: string * valueVal -> unit,
lookupFix: string -> fixityVal option,
lookupFunct: string -> functorVal option,
lookupSig: string -> signatureVal option,
lookupStruct: string -> structureVal option,
lookupType: string -> typeVal option,
lookupVal: string -> valueVal option}
type <a href="#typeExpression">typeExpression</a>
val displayTypeExpression: typeExpression * int * nameSpace -> pretty
end
val globalNameSpace: nameSpace
</pre>
<div class="entryBlock">
<pre class="entrycode"><a name="nameSpace"></a>type nameSpace =
{
allFix: unit -> (string * fixityVal) list,
allFunct: unit -> (string * functorVal) list,
allSig: unit -> (string * signatureVal) list,
allStruct: unit -> (string * structureVal) list,
allType: unit -> (string * typeVal) list,
allVal: unit -> (string * valueVal) list,
enterFix: string * fixityVal -> unit,
enterFunct: string * functorVal -> unit,
enterSig: string * signatureVal -> unit,
enterStruct: string * structureVal -> unit,
enterType: string * typeVal -> unit,
enterVal: string * valueVal -> unit,
lookupFix: string -> fixityVal option,
lookupFunct: string -> functorVal option,
lookupSig: string -> signatureVal option,
lookupStruct: string -> structureVal option,
lookupType: string -> typeVal option,
lookupVal: string -> valueVal option
}
</pre>
<div class="entrytext">
<p>The <span class="identifier">nameSpace</span> type is a record of functions.
For each class of identifier there is a lookup function that takes a string
and returns an option type, an enter function that takes a string name and
adds a values to the table and an "all" function that returns a
list of all the identifiers of that class. It is important to note that the
<span class="identifier">nameSpace</span> type does not imply any particular
implementation, it is simply an interface. Typically, it will be implemented
in terms of one or more hash-tables but it is perfectly possible to implement
something more complex. For example, <a href="PolyMLMake.html" class="identifier">PolyML.make</a>,
is implemented by passing to the compiler a name-space that has a side-effect
of checking, and if necessary recompiling, a file when called to look-up a
structure, functor or signature.</p>
</div>
</div>
<div class="entryBlock">
<pre class="entrycode"><a name="globalNameSpace"></a>val globalNameSpace: nameSpace</pre>
<div class="entrytext">
<p><span class="identifier">globalNameSpace</span> is the default name-space.
The interactive top-level, the <span class="identifier">use</span> function
and <span class="identifier">PolyML.make</span>, all use this.</p>
</div>
</div>
<div class="entryBlock">
<pre class="entrycode"><a name="valueVal" id="valueVal"></a>type valueVal
<a name="typeVal" id="typeVal"></a>type typeVal
<a name="fixityVal" id="fixityVal"></a>type fixityVal
<a name="functorVal" id="functorVal"></a>type functorVal
<a name="signatureVal" id="signatureVal"></a>type signatureVal
<a name="structureVal" id="structureVal"></a>type structureVal</pre>
<div class="entrytext"> Values of these types are the data structures used to
represent the different kind of identifiers. Values of type<span class="identifier">
valueVal </span>are used to hold information about value identifiers, <span class="identifier">typeVal</span>
is used for type constructors, <span class="identifier">fixityVal</span> for
infix status, <span class="identifier">functorVal</span> for functors, <span class="identifier">signatureVal</span>
for signatures and <span class="identifier">structureVal</span> for structures.
There are no constructors available to create values of these types; the only
way these value can be created is by compiling ML source code.</div>
</div>
<div class="entryBlock">
<pre class="entrycode"><a name="typeExpression"></a>type typeExpression</pre>
<div class="entrytext">
<p><span class="identifier">typeExpression</span> is used to represent the
type of a value. This is not really part of a name-space but is included
here, along with displayTypeExpression as a convenience. Values of this
type are returned as <a href="PolyMLStructure.html#PTtype"><span class="identifier">PTtype</span></a>
nodes in the parse-tree.</p>
</div>
</div>
<div class="entryBlock">
<pre class="entrycode"><a name="displayVal" id="displayVal"></a>val displayVal: valueVal * int * nameSpace -> pretty</pre>
<div class="entrytext">
<p>The <span class="identifier">displayVal</span> function returns a text
representation of the value as a <span class="identifier"><a href="PolyMLStructure.html#pretty">pretty</a></span>
structure. The structure returned is similar to way values are printed at
the top level and include both their value and their type. The <span class="identifier">int</span>
argument controls the depth when printing complex values. The <span class="identifier">nameSpace</span>
argument is used to assist in displaying appropriate type constructors in
the type.</p>
</div>
</div>
<ul class="nav">
<li><a href="PolyMLMake.html">Previous</a></li>
<li><a href="PolyMLStructure.html">Up</a></li>
<li><a href="#">Next</a></li>
</ul>
</body>
</html>
|