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
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="generator" content="AsciiDoc 8.6.8">
<title>MLBasisSyntaxAndSemantics</title>
<link rel="stylesheet" href="./asciidoc.css" type="text/css">
<link rel="stylesheet" href="./pygments.css" type="text/css">
<script type="text/javascript" src="./asciidoc.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
asciidoc.install();
/*]]>*/
</script>
<link rel="stylesheet" href="./mlton.css" type="text/css"/>
</head>
<body class="article">
<div id="banner">
<div id="banner-home">
<a href="./Home">MLton 20130715</a>
</div>
</div>
<div id="header">
<h1>MLBasisSyntaxAndSemantics</h1>
</div>
<div id="content">
<div id="preamble">
<div class="sectionbody">
<div class="paragraph"><p>An <a href="MLBasis">ML Basis</a> (MLB) file should have the <span class="monospaced">.mlb</span> suffix and
should contain a basis declaration.</p></div>
</div>
</div>
<div class="sect1">
<h2 id="_syntax">Syntax</h2>
<div class="sectionbody">
<div class="paragraph"><p>A basis declaration (<em>basdec</em>) must be one of the following forms.</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">basis</span> <em>basid</em> <span class="monospaced">=</span> <em>basexp</em> (<span class="monospaced">and</span> <em>basid</em> <span class="monospaced">=</span> <em>basexp</em>)<sup>*</sup>
</p>
</li>
<li>
<p>
<span class="monospaced">open</span> <em>basid<sub>1</sub></em> … <em>basid<sub>n</sub></em>
</p>
</li>
<li>
<p>
<span class="monospaced">local</span> <em>basdec</em> <span class="monospaced">in</span> <em>basdec</em> <span class="monospaced">end</span>
</p>
</li>
<li>
<p>
<em>basdec</em> [<span class="monospaced">;</span>] <em>basdec</em>
</p>
</li>
<li>
<p>
<span class="monospaced">structure</span> <em>strid</em> [<span class="monospaced">=</span> <em>strid</em>] (<span class="monospaced">and</span> <em>strid</em>[<span class="monospaced">=</span> <em>strid</em>])<sup>*</sup>
</p>
</li>
<li>
<p>
<span class="monospaced">signature</span> <em>sigid</em> [<span class="monospaced">=</span> <em>sigid</em>] (<span class="monospaced">and</span> <em>sigid</em> [<span class="monospaced">=</span> <em>sigid</em>])<sup>*</sup>
</p>
</li>
<li>
<p>
<span class="monospaced">functor</span> <em>funid</em> [<span class="monospaced">=</span> <em>funid</em>] (<span class="monospaced">and</span> <em>funid</em> [<span class="monospaced">=</span> <em>funid</em>])<sup>*</sup>
</p>
</li>
<li>
<p>
<em>path</em><span class="monospaced">.sml</span>, <em>path</em><span class="monospaced">.sig</span>, or <em>path</em><span class="monospaced">.fun</span>
</p>
</li>
<li>
<p>
<em>path</em><span class="monospaced">.mlb</span>
</p>
</li>
<li>
<p>
<span class="monospaced">ann</span> <span class="monospaced">"</span><em>ann</em><span class="monospaced">"</span> <span class="monospaced">in</span> <em>basdec</em> <span class="monospaced">end</span>
</p>
</li>
</ul></div>
<div class="paragraph"><p>A basis expression (<em>basexp</em>) must be of one the following forms.</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">bas</span> <em>basdec</em> <span class="monospaced">end</span>
</p>
</li>
<li>
<p>
<em>basid</em>
</p>
</li>
<li>
<p>
<span class="monospaced">let</span> <em>basdec</em> <span class="monospaced">in</span> <em>basexp</em> <span class="monospaced">end</span>
</p>
</li>
</ul></div>
<div class="paragraph"><p>Nested SML-style comments (enclosed with <span class="monospaced">(*</span> and <span class="monospaced">*)</span>) are ignored
(but <a href="LineDirective">LineDirective</a>s are recognized).</p></div>
<div class="paragraph"><p>Paths can be relative or absolute. Relative paths are relative to the
directory containing the MLB file. Paths may include path variables
and are expanded according to a <a href="MLBasisPathMap">path map</a>. Unquoted
paths may include alpha-numeric characters and the symbols "<span class="monospaced">-</span>" and
"<span class="monospaced">_</span>", along with the arc separator "<span class="monospaced">/</span>" and extension separator
"<span class="monospaced">.</span>". More complicated paths, including paths with spaces, may be
included by quoting the path with <span class="monospaced">"</span>. A quoted path is lexed as an
SML string constant.</p></div>
<div class="paragraph"><p><a href="MLBasisAnnotations">Annotations</a> allow a library author to
control options that affect the elaboration of SML source files.</p></div>
</div>
</div>
<div class="sect1">
<h2 id="_semantics">Semantics</h2>
<div class="sectionbody">
<div class="paragraph"><p>There is a <a href="MLBasis.attachments/mlb-formal.pdf">formal semantics</a> for
ML Basis files in the style of the
<a href="DefinitionOfStandardML">Definition</a>. Here, we give an informal
explanation.</p></div>
<div class="paragraph"><p>An SML structure is a collection of types, values, and other
structures. Similarly, a basis is a collection, but of more kinds of
objects: types, values, structures, fixities, signatures, functors,
and other bases.</p></div>
<div class="paragraph"><p>A basis declaration denotes a basis. A structure, signature, or
functor declaration denotes a basis containing the corresponding
module. Sequencing of basis declarations merges bases, with later
definitions taking precedence over earlier ones, just like sequencing
of SML declarations. Local declarations provide name hiding, just
like SML local declarations. A reference to an SML source file causes
the file to be elaborated in the basis extant at the point of
reference. A reference to an MLB file causes the basis denoted by
that MLB file to be imported — the basis at the point of reference
does <em>not</em> affect the imported basis.</p></div>
<div class="paragraph"><p>Basis expressions and basis identifiers allow binding a basis to a
name.</p></div>
<div class="paragraph"><p>An MLB file is elaborated starting in an empty basis. Each MLB file
is elaborated and evaluated only once, with the result being cached.
Subsequent references use the cached value. Thus, any observable
effects due to evaluation are not duplicated if the MLB file is
referred to multiple times.</p></div>
</div>
</div>
</div>
<div id="footnotes"><hr></div>
<div id="footer">
<div id="footer-text">
</div>
<div id="footer-badges">
</div>
</div>
</body>
</html>
|