Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > d07d7ab417d79053e7e0155c99e1a1c8 > files > 2429

mlton-20100608-3.fc15.i686.rpm

<!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>
      &nbsp;<a href = "TitleIndex">Index</a>
      &nbsp;
</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&nbsp;.&nbsp;x</tt>.  Section 2.5 of the Definition implies that <tt>S&nbsp;.&nbsp;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 -&gt; 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&nbsp;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&nbsp;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">&quot;one&quot;</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 =&gt; 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 =&gt; 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&nbsp;vector</tt>, not <tt>eqtype&nbsp;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">&quot;&quot;</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&nbsp;=&nbsp;true</tt> and <tt>vol&nbsp;=&nbsp;""</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">&quot;\\usr\\local&quot;</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>