/usr/share/doc/mlton/guide/SMLNJDeviations is in mlton-doc 20100608-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta name="robots" content="index,nofollow">
<title>SMLNJDeviations - MLton Standard ML Compiler (SML Compiler)</title>
<link rel="stylesheet" type="text/css" charset="iso-8859-1" media="all" href="common.css">
<link rel="stylesheet" type="text/css" charset="iso-8859-1" media="screen" href="screen.css">
<link rel="stylesheet" type="text/css" charset="iso-8859-1" media="print" href="print.css">
<link rel="Start" href="Home">
</head>
<body lang="en" dir="ltr">
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-833377-1";
urchinTracker();
</script>
<table bgcolor = lightblue cellspacing = 0 style = "border: 0px;" width = 100%>
<tr>
<td style = "
border: 0px;
color: darkblue;
font-size: 150%;
text-align: left;">
<a class = mltona href="Home">MLton MLTONWIKIVERSION</a>
<td style = "
border: 0px;
font-size: 150%;
text-align: center;
width: 50%;">
SMLNJDeviations
<td style = "
border: 0px;
text-align: right;">
<table cellspacing = 0 style = "border: 0px">
<tr style = "vertical-align: middle;">
</table>
<tr style = "background-color: white;">
<td colspan = 3
style = "
border: 0px;
font-size:70%;
text-align: right;">
<a href = "Home">Home</a>
<a href = "TitleIndex">Index</a>
</table>
<div id="content" lang="en" dir="ltr">
Here are some deviations of <a href="SMLNJ">SML/NJ</a> from <a href="DefinitionOfStandardML">The Definition of Standard ML</a>. Some of these are documented in the <a class="external" href="http://www.smlnj.org/doc/Conversion/index.html"><img src="moin-www.png" alt="[WWW]" height="11" width="11">SML '97 Conversion Guide</a>. Since MLton does not deviate from the Definition, you should look here if you are having trouble porting a program from MLton to SML/NJ or vice versa. If you discover other deviations of SML/NJ that aren't listed here, please send mail to <a class="external" href="mailto:MLton@mlton.org"><img src="moin-email.png" alt="[MAILTO]" height="10" width="14">MLton@mlton.org</a>.
<ul>
<li>
<p>
SML/NJ allows spaces in long identifiers, as in <tt>S . x</tt>. Section 2.5 of the Definition implies that <tt>S . x</tt> should be treated as three separate lexical items.
</p>
</li>
<li class="gap">
<p>
SML/NJ allows <tt>op</tt> to appear in <tt>val</tt> specifications:
<pre class=code>
<B><FONT COLOR="#0000FF">signature</FONT></B> FOO = <B><FONT COLOR="#0000FF">sig</FONT></B>
<B><FONT COLOR="#A020F0">val</FONT></B> <B><FONT COLOR="#A020F0">op</FONT></B> + : int * int -> int
<B><FONT COLOR="#0000FF">end</FONT></B>
</PRE>
The grammar on page 14 of the Definition does not allow it. Recent versions of SML/NJ do give a warning.
</p>
</li>
<li class="gap">
<p>
SML/NJ rejects
<pre class=code>
(<B><FONT COLOR="#A020F0">op</FONT></B> *)
</PRE>
as an unmatched close comment.
</p>
</li>
<li class="gap">
<p>
SML/NJ allows <tt>=</tt> to be rebound by the declaration:
<pre class=code>
<B><FONT COLOR="#A020F0">val</FONT></B> <B><FONT COLOR="#A020F0">op</FONT></B> = = <B><FONT COLOR="#5F9EA0">13</FONT></B>
</PRE>
This is explicitly forbidden on page 5 of the Definition. Recent versions of SML/NJ do give a warning.
</p>
</li>
<li class="gap">
<p>
SML/NJ allows rebinding <tt>true</tt>, <tt>false</tt>, <tt>nil</tt>, <tt>::</tt>, and <tt>ref</tt> by the declarations:
<pre class=code>
<B><FONT COLOR="#A020F0">fun</FONT></B> true () = ()
<B><FONT COLOR="#A020F0">fun</FONT></B> false () = ()
<B><FONT COLOR="#A020F0">fun</FONT></B> nil () = ()
<B><FONT COLOR="#A020F0">fun</FONT></B> <B><FONT COLOR="#A020F0">op</FONT></B> :: () = ()
<B><FONT COLOR="#A020F0">fun</FONT></B> ref () = ()
</PRE>
This is explicitly forbidden on page 9 of the Definition.
</p>
</li>
<li class="gap">
<p>
SML/NJ extends the syntax of the language to allow vector expressions and patterns like the following:
<pre class=code>
<B><FONT COLOR="#A020F0">val</FONT></B> v = #[<B><FONT COLOR="#5F9EA0">1</FONT></B>,<B><FONT COLOR="#5F9EA0">2</FONT></B>,<B><FONT COLOR="#5F9EA0">3</FONT></B>]
<B><FONT COLOR="#A020F0">val</FONT></B> #[x,y,z] = v
</PRE>
</p>
</li>
<li class="gap">
<p>
SML/NJ extends the syntax of the language to allow <em>or patterns</em> like the following:
<pre class=code>
<B><FONT COLOR="#A020F0">datatype</FONT></B><B><FONT COLOR="#228B22"> foo </FONT></B>=<B><FONT COLOR="#228B22"> <FONT COLOR="#B8860B">Foo</FONT> <B><FONT COLOR="#A020F0">of</FONT></B> int </FONT></B>|<B><FONT COLOR="#228B22"> <FONT COLOR="#B8860B">Bar</FONT> <B><FONT COLOR="#A020F0">of</FONT></B> int
</FONT></B><B><FONT COLOR="#A020F0">val</FONT></B> (Foo x | Bar x) = Foo <B><FONT COLOR="#5F9EA0">13</FONT></B>
</PRE>
</p>
</li>
<li class="gap">
<p>
SML/NJ allows higher-order functors, that is, functors can be components of structures and can be passed as functor arguments and returned as functor results. As a consequence, SML/NJ allows abbreviated functor definitions, as in the following:
<pre class=code>
<B><FONT COLOR="#0000FF">signature</FONT></B> S =
<B><FONT COLOR="#0000FF">sig</FONT></B>
<B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> t
</FONT></B><B><FONT COLOR="#A020F0">val</FONT></B> x: t
<B><FONT COLOR="#0000FF">end</FONT></B>
<B><FONT COLOR="#0000FF">functor</FONT></B> F (<B><FONT COLOR="#0000FF">structure</FONT></B> A: S): S =
<B><FONT COLOR="#0000FF">struct</FONT></B>
<B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> t </FONT></B>=<B><FONT COLOR="#228B22"> A.t * A.t
</FONT></B><B><FONT COLOR="#A020F0">val</FONT></B> x = (A.x, A.x)
<B><FONT COLOR="#0000FF">end</FONT></B>
<B><FONT COLOR="#0000FF">functor</FONT></B> G = F
</PRE>
</p>
</li>
<li class="gap">
<p>
SML/NJ extends the syntax of the language to allow functor and signature definitions to occur within the scope of <tt>local</tt> and <tt>structure</tt> declarations.
</p>
</li>
<li class="gap">
<p>
SML/NJ allows duplicate type specifications in signatures when the duplicates are introduced by <tt>include</tt>, as in the following:
<pre class=code>
<B><FONT COLOR="#0000FF">signature</FONT></B> SIG1 =
<B><FONT COLOR="#0000FF">sig</FONT></B>
<B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> t
</FONT></B><B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> u
</FONT></B><B><FONT COLOR="#0000FF">end</FONT></B>
<B><FONT COLOR="#0000FF">signature</FONT></B> SIG2 =
<B><FONT COLOR="#0000FF">sig</FONT></B>
<B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> t
</FONT></B><B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> v
</FONT></B><B><FONT COLOR="#0000FF">end</FONT></B>
<B><FONT COLOR="#0000FF">signature</FONT></B> SIG =
<B><FONT COLOR="#0000FF">sig</FONT></B>
<B><FONT COLOR="#0000FF">include</FONT></B> SIG1
<B><FONT COLOR="#0000FF">include</FONT></B> SIG2
<B><FONT COLOR="#0000FF">end</FONT></B>
</PRE>
This is disallowed by rule 77 of the Definition.
</p>
</li>
<li class="gap">
<p>
SML/NJ allows sharing constraints between type abbreviations in signatures, as in the following:
<pre class=code>
<B><FONT COLOR="#0000FF">signature</FONT></B> SIG =
<B><FONT COLOR="#0000FF">sig</FONT></B>
<B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> t </FONT></B>=<B><FONT COLOR="#228B22"> int * int
</FONT></B><B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> u </FONT></B>=<B><FONT COLOR="#228B22"> int * int
</FONT></B><B><FONT COLOR="#0000FF">sharing</FONT></B> <B><FONT COLOR="#0000FF">type</FONT></B><B><FONT COLOR="#228B22"> t </FONT></B>=<B><FONT COLOR="#228B22"> u
</FONT></B><B><FONT COLOR="#0000FF">end</FONT></B>
</PRE>
These are disallowed by rule 78 of the Definition. Recent versions of SML/NJ correctly disallow sharing constraints between type abbreviations in signatures.
</p>
</li>
<li class="gap">
<p>
SML/NJ disallows multiple <tt>where type</tt> specifications of the same type name, as in the following
<pre class=code>
<B><FONT COLOR="#0000FF">signature</FONT></B> S =
<B><FONT COLOR="#0000FF">sig</FONT></B>
<B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> t
</FONT></B><B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> u </FONT></B>=<B><FONT COLOR="#228B22"> t
</FONT></B><B><FONT COLOR="#0000FF">end</FONT></B>
<B><FONT COLOR="#0000FF">where</FONT></B> <B><FONT COLOR="#0000FF">type</FONT></B><B><FONT COLOR="#228B22"> u </FONT></B>=<B><FONT COLOR="#228B22"> int
</FONT></B></PRE>
This is allowed by rule 84 of the Definition.
</p>
</li>
<li class="gap">
<p>
SML/NJ allows <tt>and</tt> in <tt>sharing</tt> specs in signatures, as in
<pre class=code>
<B><FONT COLOR="#A020F0">signature</FONT></B> S =
<B><FONT COLOR="#A020F0">sig</FONT></B>
<B><FONT COLOR="#A020F0">type</FONT></B> t
<B><FONT COLOR="#A020F0">type</FONT></B> u
<B><FONT COLOR="#A020F0">type</FONT></B> v
<B><FONT COLOR="#A020F0">sharing</FONT></B> <B><FONT COLOR="#A020F0">type</FONT></B> t = u
<B><FONT COLOR="#A020F0">and</FONT></B> <B><FONT COLOR="#A020F0">type</FONT></B> u = v
<B><FONT COLOR="#A020F0">end</FONT></B>
</PRE>
</p>
</li>
<li class="gap">
<p>
SML/NJ does not expand the <tt>withtype</tt> derived form as described by the Definition. According to page 55 of the Definition, the type bindings of a <tt>withtype</tt> declaration are substituted simultaneously in the connected datatype. Consider the following program.
<pre class=code>
<B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> u </FONT></B>=<B><FONT COLOR="#228B22"> real </FONT></B>;
<B><FONT COLOR="#A020F0">datatype</FONT></B><B><FONT COLOR="#228B22"> a </FONT></B>=<B><FONT COLOR="#228B22">
<FONT COLOR="#B8860B">A</FONT> <B><FONT COLOR="#A020F0">of</FONT></B> t
</FONT></B>|<B><FONT COLOR="#228B22"> <FONT COLOR="#B8860B">B</FONT> <B><FONT COLOR="#A020F0">of</FONT></B> u
</FONT></B><B><FONT COLOR="#A020F0">withtype</FONT></B><B><FONT COLOR="#228B22"> u </FONT></B>=<B><FONT COLOR="#228B22"> int
</FONT></B><B><FONT COLOR="#A020F0">and</FONT></B><B><FONT COLOR="#228B22"> t </FONT></B>=<B><FONT COLOR="#228B22"> u
</FONT></B></PRE>
According to the Definition, it should be expanded to the following.
<pre class=code>
<B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> u </FONT></B>=<B><FONT COLOR="#228B22"> real </FONT></B>;
<B><FONT COLOR="#A020F0">datatype</FONT></B><B><FONT COLOR="#228B22"> a </FONT></B>=<B><FONT COLOR="#228B22">
<FONT COLOR="#B8860B">A</FONT> <B><FONT COLOR="#A020F0">of</FONT></B> u
</FONT></B>|<B><FONT COLOR="#228B22"> <FONT COLOR="#B8860B">B</FONT> <B><FONT COLOR="#A020F0">of</FONT></B> int </FONT></B>;
<B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> u </FONT></B>=<B><FONT COLOR="#228B22"> int
</FONT></B><B><FONT COLOR="#A020F0">and</FONT></B><B><FONT COLOR="#228B22"> t </FONT></B>=<B><FONT COLOR="#228B22"> u
</FONT></B></PRE>
However, SML/NJ expands <tt>withtype</tt> bindings sequentially, meaning that earlier bindings are expanded within later ones. Hence, the above program is expanded to the following.
<pre class=code>
<B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> u </FONT></B>=<B><FONT COLOR="#228B22"> real </FONT></B>;
<B><FONT COLOR="#A020F0">datatype</FONT></B><B><FONT COLOR="#228B22"> a </FONT></B>=<B><FONT COLOR="#228B22">
<FONT COLOR="#B8860B">A</FONT> <B><FONT COLOR="#A020F0">of</FONT></B> int
</FONT></B>|<B><FONT COLOR="#228B22"> <FONT COLOR="#B8860B">B</FONT> <B><FONT COLOR="#A020F0">of</FONT></B> int </FONT></B>;
<B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> u </FONT></B>=<B><FONT COLOR="#228B22"> int
</FONT></B><B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> t </FONT></B>=<B><FONT COLOR="#228B22"> int
</FONT></B></PRE>
</p>
</li>
<li class="gap">
<p>
SML/NJ allows <tt>withtype</tt> specifications in signatures.
</p>
</li>
<li class="gap">
<p>
SML/NJ allows a <tt>where</tt> structure specification that is similar to a <tt>where type</tt> specification. For example:
<pre class=code>
<B><FONT COLOR="#0000FF">structure</FONT></B> S = <B><FONT COLOR="#0000FF">struct</FONT></B> <B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> t </FONT></B>=<B><FONT COLOR="#228B22"> int </FONT></B><B><FONT COLOR="#0000FF">end</FONT></B>
<B><FONT COLOR="#0000FF">signature</FONT></B> SIG =
<B><FONT COLOR="#0000FF">sig</FONT></B>
<B><FONT COLOR="#0000FF">structure</FONT></B> T : <B><FONT COLOR="#0000FF">sig</FONT></B> <B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> t </FONT></B><B><FONT COLOR="#0000FF">end</FONT></B>
<B><FONT COLOR="#0000FF">end</FONT></B> <B><FONT COLOR="#0000FF">where</FONT></B> T = S
</PRE>
This is equivalent to:
<pre class=code>
<B><FONT COLOR="#0000FF">structure</FONT></B> S = <B><FONT COLOR="#0000FF">struct</FONT></B> <B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> t </FONT></B>=<B><FONT COLOR="#228B22"> int </FONT></B><B><FONT COLOR="#0000FF">end</FONT></B>
<B><FONT COLOR="#0000FF">signature</FONT></B> SIG =
<B><FONT COLOR="#0000FF">sig</FONT></B>
<B><FONT COLOR="#0000FF">structure</FONT></B> T : <B><FONT COLOR="#0000FF">sig</FONT></B> <B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> t </FONT></B><B><FONT COLOR="#0000FF">end</FONT></B>
<B><FONT COLOR="#0000FF">end</FONT></B> <B><FONT COLOR="#0000FF">where</FONT></B> <B><FONT COLOR="#0000FF">type</FONT></B><B><FONT COLOR="#228B22"> T.t </FONT></B>=<B><FONT COLOR="#228B22"> S.t
</FONT></B></PRE>
SML/NJ also allows a definitional structure specification that is similar to a definitional type specification. For example:
<pre class=code>
<B><FONT COLOR="#0000FF">structure</FONT></B> S = <B><FONT COLOR="#0000FF">struct</FONT></B> <B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> t </FONT></B>=<B><FONT COLOR="#228B22"> int </FONT></B><B><FONT COLOR="#0000FF">end</FONT></B>
<B><FONT COLOR="#0000FF">signature</FONT></B> SIG =
<B><FONT COLOR="#0000FF">sig</FONT></B>
<B><FONT COLOR="#0000FF">structure</FONT></B> T : <B><FONT COLOR="#0000FF">sig</FONT></B> <B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> t </FONT></B><B><FONT COLOR="#0000FF">end</FONT></B> = S
<B><FONT COLOR="#0000FF">end</FONT></B>
</PRE>
This is equivalent to the previous examples and to:
<pre class=code>
<B><FONT COLOR="#0000FF">structure</FONT></B> S = <B><FONT COLOR="#0000FF">struct</FONT></B> <B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> t </FONT></B>=<B><FONT COLOR="#228B22"> int </FONT></B><B><FONT COLOR="#0000FF">end</FONT></B>
<B><FONT COLOR="#0000FF">signature</FONT></B> SIG =
<B><FONT COLOR="#0000FF">sig</FONT></B>
<B><FONT COLOR="#0000FF">structure</FONT></B> T : <B><FONT COLOR="#0000FF">sig</FONT></B> <B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> t </FONT></B><B><FONT COLOR="#0000FF">end</FONT></B> <B><FONT COLOR="#0000FF">where</FONT></B> <B><FONT COLOR="#0000FF">type</FONT></B><B><FONT COLOR="#228B22"> t </FONT></B>=<B><FONT COLOR="#228B22"> S.t
</FONT></B><B><FONT COLOR="#0000FF">end</FONT></B>
</PRE>
</p>
</li>
<li class="gap">
<p>
SML/NJ disallows binding non-datatypes with datatype replication. For example, it rejects the following program that should be allowed according to the Definition.
<pre class=code>
<B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> ('a, 'b) t </FONT></B>=<B><FONT COLOR="#228B22"> 'a * 'b
</FONT></B><B><FONT COLOR="#A020F0">datatype</FONT></B><B><FONT COLOR="#228B22"> u </FONT></B>=<B><FONT COLOR="#228B22"> <B><FONT COLOR="#A020F0">datatype</FONT></B> t
</FONT></B></PRE>
This idiom can be useful when one wants to rename a type without rewriting all the type arguments. For example, the above would have to be written in SML/NJ as follows.
<pre class=code>
<B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> ('a, 'b) t </FONT></B>=<B><FONT COLOR="#228B22"> 'a * 'b
</FONT></B><B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> ('a, 'b) u </FONT></B>=<B><FONT COLOR="#228B22"> ('a, 'b) t
</FONT></B></PRE>
</p>
</li>
<li class="gap">
<p>
SML/NJ disallows sharing a structure with one of its substructures. For example, SML/NJ disallows the following.
<pre class=code>
<B><FONT COLOR="#0000FF">signature</FONT></B> SIG =
<B><FONT COLOR="#0000FF">sig</FONT></B>
<B><FONT COLOR="#0000FF">structure</FONT></B> S:
<B><FONT COLOR="#0000FF">sig</FONT></B>
<B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> t
</FONT></B><B><FONT COLOR="#0000FF">structure</FONT></B> T: <B><FONT COLOR="#0000FF">sig</FONT></B> <B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> t </FONT></B><B><FONT COLOR="#0000FF">end</FONT></B>
<B><FONT COLOR="#0000FF">end</FONT></B>
<B><FONT COLOR="#0000FF">sharing</FONT></B> S = S.T
<B><FONT COLOR="#0000FF">end</FONT></B>
</PRE>
This signature is allowed by the Definition.
</p>
</li>
<li class="gap">
<p>
SML/NJ disallows polymorphic generalization of refutable patterns. For example, SML/NJ disallows the following.
<pre class=code>
<B><FONT COLOR="#A020F0">val</FONT></B> [x] = [[]]
<B><FONT COLOR="#A020F0">val</FONT></B> _ = (<B><FONT COLOR="#5F9EA0">1</FONT></B> :: x, <B><FONT COLOR="#BC8F8F">"one"</FONT></B> :: x)
</PRE>
Recent versions of SML/NJ correctly allow polymorphic generalization of refutable patterns.
</p>
</li>
<li class="gap">
<p>
SML/NJ uses an overly restrictive context for type inference. For example, SML/NJ rejects both of the following.
<pre class=code>
<B><FONT COLOR="#0000FF">structure</FONT></B> S =
<B><FONT COLOR="#0000FF">struct</FONT></B>
<B><FONT COLOR="#A020F0">val</FONT></B> z = (<B><FONT COLOR="#A020F0">fn</FONT></B> x => x) []
<B><FONT COLOR="#A020F0">val</FONT></B> y = z :: [true] :: nil
<B><FONT COLOR="#0000FF">end</FONT></B>
</PRE>
<pre class=code>
<B><FONT COLOR="#0000FF">structure</FONT></B> S : <B><FONT COLOR="#0000FF">sig</FONT></B> <B><FONT COLOR="#A020F0">val</FONT></B> z : bool list <B><FONT COLOR="#0000FF">end</FONT></B> =
<B><FONT COLOR="#0000FF">struct</FONT></B>
<B><FONT COLOR="#A020F0">val</FONT></B> z = (<B><FONT COLOR="#A020F0">fn</FONT></B> x => x) []
<B><FONT COLOR="#0000FF">end</FONT></B>
</PRE>
These structures are allowed by the Definition.
</p>
</li>
</ul>
<h2 id="head-b075a95ec6d7bcb0b6a2ee7dbf5fac2093ba1e54">Deviations from the Basis Library Specification</h2>
<p>
Here are some deviations of SML/NJ from the Basis Library Specification.
</p>
<ul>
<li>
<p>
SML/NJ exposes the equality of the <tt>vector</tt> type in structures such as <tt>Word8Vector</tt> that abstractly match <tt>MONO_VECTOR</tt>, which says <tt>type vector</tt>, not <tt>eqtype vector</tt>. So, for example, SML/NJ accepts the following program:
<pre class=code>
<B><FONT COLOR="#A020F0">fun</FONT></B> f (v: Word8Vector.vector) = v = v
</PRE>
</p>
</li>
<li class="gap">
<p>
SML/NJ exposes the equality property of the type <tt>status</tt> in <tt>OS.Process</tt>. This means that programs which directly compare two values of type <tt>status</tt> will work with SML/NJ but not MLton.
</p>
</li>
<li class="gap">
<p>
Under SML/NJ on Windows, <tt>OS.Path.validVolume</tt> incorrectly considers absolute empty volumes to be valid. In other words, when the expression
<pre class=code>
OS.Path.validVolume { isAbs = true, vol = <B><FONT COLOR="#BC8F8F">""</FONT></B> }
</PRE>
is evaluated by SML/NJ on Windows, the result is <tt>true</tt>. MLton, on the other hand, correctly follows the Basis Library Specification, which states that on Windows, <tt>OS.Path.validVolume</tt> should return <tt>false</tt> whenever <tt>isAbs = true</tt> and <tt>vol = ""</tt>.
</p>
This incorrect behavior causes other <tt>OS.Path</tt> functions to behave differently. For example, when the expression
<pre class=code>
OS.Path.toString (OS.Path.fromString <B><FONT COLOR="#BC8F8F">"\\usr\\local"</FONT></B>)
</PRE>
<p>
is evaluated by SML/NJ on Windows, the result is <tt>"\\usr\\local"</tt>, whereas under MLton on Windows, evaluating this expression (correctly) causes an <tt>OS.Path.Path</tt> exception to be raised.
</p>
</li>
</ul>
</div>
<p>
<hr>
Last edited on 2010-05-20 18:27:00 by <span title="fenrir.cs.rit.edu"><a href="MatthewFluet">MatthewFluet</a></span>.
</body></html>
|