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
|
<!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="PolyMLProfiling.html">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
structure Functors:<br> sig<br> val code = fn: functorVal -> CodeTree.codetree<br> type functorVal<br> val name = fn: functorVal -> string<br> val print = fn: functorVal * int * nameSpace option -> pretty<br> val properties = fn: functorVal -> ptProperties list<br> end<br> structure Infixes:<br> sig<br> type fixity<br> val name = fn: fixity -> string<br> val print = fn: fixity -> pretty<br> end<br> structure Signatures:<br> sig<br> val name = fn: signatureVal -> string<br> val print = fn: signatureVal * int * nameSpace option -> pretty<br> val properties = fn: signatureVal -> ptProperties list<br> type signatureVal<br> end<br> structure Structures:<br> sig<br> val code = fn: structureVal -> CodeTree.codetree
val contents = fn: structureVal -> nameSpace<br> val name = fn: structureVal -> string<br> val print = fn: structureVal * int * nameSpace option -> pretty<br> val properties = fn: structureVal -> ptProperties list<br> type structureVal<br> end<br> structure TypeConstrs:<br> sig<br> val name = fn: typeConstr -> string<br> val print = fn: typeConstr * int * nameSpace option -> pretty<br> val properties = fn: typeConstr -> ptProperties list<br> type typeConstr<br> end<br> structure Values:<br> sig<br> val code = fn: value -> CodeTree.codetree<br> val isConstructor = fn: value -> bool<br> val isException = fn: value -> bool<br> val name = fn: value -> string<br> val print = fn: value * int -> pretty<br> val printType = fn:<br> typeExpression * int * nameSpace option -> pretty<br> val printWithType = fn: value * int * nameSpace option -> pretty<br> val properties = fn: value -> ptProperties list<br> type typeExpression<br> val typeof = fn: value -> typeExpression<br> type value<br> end<br> type <a href="#nameSpace">nameSpace</a> =<br> {allFix: unit -> (string * Infixes.fixity) list,<br> allFunct: unit -> (string * Functors.functorVal) list,<br> allSig: unit -> (string * Signatures.signatureVal) list,<br> allStruct: unit -> (string * Structures.structureVal) list,<br> allType: unit -> (string * TypeConstrs.typeConstr) list,<br> allVal: unit -> (string * Values.value) list,<br> enterFix: string * Infixes.fixity -> unit,<br> enterFunct: string * Functors.functorVal -> unit,<br> enterSig: string * Signatures.signatureVal -> unit,<br> enterStruct: string * Structures.structureVal -> unit,<br> enterType: string * TypeConstrs.typeConstr -> unit,<br> enterVal: string * Values.value -> unit,<br> lookupFix: string -> Infixes.fixity option,<br> lookupFunct: string -> Functors.functorVal option,<br> lookupSig: string -> Signatures.signatureVal option,<br> lookupStruct: string -> Structures.structureVal option,<br> lookupType: string -> TypeConstrs.typeConstr option,<br> lookupVal: string -> Values.value option}<br> end
val globalNameSpace: nameSpace
</pre>
<div class="entryBlock">
<pre class="entrycode"><a name="nameSpace"></a>type nameSpace =<br> {allFix: unit -> (string * Infixes.fixity) list,<br> allFunct: unit -> (string * Functors.functorVal) list,<br> allSig: unit -> (string * Signatures.signatureVal) list,<br> allStruct: unit -> (string * Structures.structureVal) list,<br> allType: unit -> (string * TypeConstrs.typeConstr) list,<br> allVal: unit -> (string * Values.value) list,<br> enterFix: string * Infixes.fixity -> unit,<br> enterFunct: string * Functors.functorVal -> unit,<br> enterSig: string * Signatures.signatureVal -> unit,<br> enterStruct: string * Structures.structureVal -> unit,<br> enterType: string * TypeConstrs.typeConstr -> unit,<br> enterVal: string * Values.value -> unit,<br> lookupFix: string -> Infixes.fixity option,<br> lookupFunct: string -> Functors.functorVal option,<br> lookupSig: string -> Signatures.signatureVal option,<br> lookupStruct: string -> Structures.structureVal option,<br> lookupType: string -> TypeConstrs.typeConstr option,<br> lookupVal: string -> Values.value option}<br></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="PolyMLProfiling.html">Next</a></li>
</ul>
</body>
</html>
|