This file is indexed.

/usr/share/doc/mlton/guide/MLtonStructure 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
406
407
408
409
<!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>MLtonStructure - 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%;">
      MLtonStructure
    <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">
The <tt>MLton</tt> structure contains a lot of functionality that is not available in the <a href="BasisLibrary">Basis Library</a>.  As a warning, please keep in mind that the <tt>MLton</tt> structure and its substructures do change from release to release of MLton. 
<pre class=code>
<B><FONT COLOR="#0000FF">structure</FONT></B> MLton:
   <B><FONT COLOR="#0000FF">sig</FONT></B>
      <B><FONT COLOR="#A020F0">val</FONT></B> eq: 'a * 'a -&gt; bool
      <B><FONT COLOR="#A020F0">val</FONT></B> equal: 'a * 'a -&gt; bool
      <B><FONT COLOR="#A020F0">val</FONT></B> hash: 'a -&gt; Word32.word
      <B><FONT COLOR="#A020F0">val</FONT></B> isMLton: bool
      <B><FONT COLOR="#A020F0">val</FONT></B> share: 'a -&gt; unit
      <B><FONT COLOR="#A020F0">val</FONT></B> shareAll: unit -&gt; unit
      <B><FONT COLOR="#A020F0">val</FONT></B> size: 'a -&gt; int

      <B><FONT COLOR="#0000FF">structure</FONT></B> Array: MLTON_ARRAY
      <B><FONT COLOR="#0000FF">structure</FONT></B> BinIO: MLTON_BIN_IO
      <B><FONT COLOR="#0000FF">structure</FONT></B> CharArray: MLTON_MONO_ARRAY <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"> CharArray.array
                                            </FONT></B><B><FONT COLOR="#0000FF">where</FONT></B> <B><FONT COLOR="#0000FF">type</FONT></B><B><FONT COLOR="#228B22"> elem </FONT></B>=<B><FONT COLOR="#228B22"> CharArray.elem
      </FONT></B><B><FONT COLOR="#0000FF">structure</FONT></B> CharVector: MLTON_MONO_VECTOR <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"> CharVector.vector
                                              </FONT></B><B><FONT COLOR="#0000FF">where</FONT></B> <B><FONT COLOR="#0000FF">type</FONT></B><B><FONT COLOR="#228B22"> elem </FONT></B>=<B><FONT COLOR="#228B22"> CharVector.elem
      </FONT></B><B><FONT COLOR="#0000FF">structure</FONT></B> Cont: MLTON_CONT
      <B><FONT COLOR="#0000FF">structure</FONT></B> Exn: MLTON_EXN
      <B><FONT COLOR="#0000FF">structure</FONT></B> Finalizable: MLTON_FINALIZABLE
      <B><FONT COLOR="#0000FF">structure</FONT></B> GC: MLTON_GC
      <B><FONT COLOR="#0000FF">structure</FONT></B> IntInf: MLTON_INT_INF
      <B><FONT COLOR="#0000FF">structure</FONT></B> Itimer: MLTON_ITIMER
      <B><FONT COLOR="#0000FF">structure</FONT></B> LargeReal: MLTON_REAL <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"> LargeReal.real
      </FONT></B><B><FONT COLOR="#0000FF">structure</FONT></B> LargeWord: MLTON_WORD <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"> LargeWord.word
      </FONT></B><B><FONT COLOR="#0000FF">structure</FONT></B> Platform: MLTON_PLATFORM
      <B><FONT COLOR="#0000FF">structure</FONT></B> Pointer: MLTON_POINTER
      <B><FONT COLOR="#0000FF">structure</FONT></B> ProcEnv: MLTON_PROC_ENV
      <B><FONT COLOR="#0000FF">structure</FONT></B> Process: MLTON_PROCESS
      <B><FONT COLOR="#0000FF">structure</FONT></B> Profile: MLTON_PROFILE
      <B><FONT COLOR="#0000FF">structure</FONT></B> Random: MLTON_RANDOM
      <B><FONT COLOR="#0000FF">structure</FONT></B> Real: MLTON_REAL <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"> Real.real
      </FONT></B><B><FONT COLOR="#0000FF">structure</FONT></B> Real32: <B><FONT COLOR="#0000FF">sig</FONT></B>
                           <B><FONT COLOR="#0000FF">include</FONT></B> MLTON_REAL
                           <B><FONT COLOR="#A020F0">val</FONT></B> castFromWord: Word32.word -&gt; t
                           <B><FONT COLOR="#A020F0">val</FONT></B> castToWord: t -&gt; Word32.word
                        <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"> Real32.real
      </FONT></B><B><FONT COLOR="#0000FF">structure</FONT></B> Real64: <B><FONT COLOR="#0000FF">sig</FONT></B>
                           <B><FONT COLOR="#0000FF">include</FONT></B> MLTON_REAL
                           <B><FONT COLOR="#A020F0">val</FONT></B> castFromWord: Word64.word -&gt; t
                           <B><FONT COLOR="#A020F0">val</FONT></B> castToWord: t -&gt; Word64.word
                        <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"> Real64.real
      </FONT></B><B><FONT COLOR="#0000FF">structure</FONT></B> Rlimit: MLTON_RLIMIT
      <B><FONT COLOR="#0000FF">structure</FONT></B> Rusage: MLTON_RUSAGE
      <B><FONT COLOR="#0000FF">structure</FONT></B> Signal: MLTON_SIGNAL
      <B><FONT COLOR="#0000FF">structure</FONT></B> Socket: MLTON_SOCKET
      <B><FONT COLOR="#0000FF">structure</FONT></B> Syslog: MLTON_SYSLOG
      <B><FONT COLOR="#0000FF">structure</FONT></B> TextIO: MLTON_TEXT_IO
      <B><FONT COLOR="#0000FF">structure</FONT></B> Thread: MLTON_THREAD
      <B><FONT COLOR="#0000FF">structure</FONT></B> Vector: MLTON_VECTOR
      <B><FONT COLOR="#0000FF">structure</FONT></B> Weak: MLTON_WEAK
      <B><FONT COLOR="#0000FF">structure</FONT></B> Word: MLTON_WORD <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"> Word.word
      </FONT></B><B><FONT COLOR="#0000FF">structure</FONT></B> Word8: MLTON_WORD <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"> Word8.word
      </FONT></B><B><FONT COLOR="#0000FF">structure</FONT></B> Word16: MLTON_WORD <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"> Word16.word
      </FONT></B><B><FONT COLOR="#0000FF">structure</FONT></B> Word32: MLTON_WORD <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"> Word32.word
      </FONT></B><B><FONT COLOR="#0000FF">structure</FONT></B> Word64: MLTON_WORD <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"> Word64.word
      </FONT></B><B><FONT COLOR="#0000FF">structure</FONT></B> Word8Array: MLTON_MONO_ARRAY <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"> Word8Array.array
                                             </FONT></B><B><FONT COLOR="#0000FF">where</FONT></B> <B><FONT COLOR="#0000FF">type</FONT></B><B><FONT COLOR="#228B22"> elem </FONT></B>=<B><FONT COLOR="#228B22"> Word8Array.elem
      </FONT></B><B><FONT COLOR="#0000FF">structure</FONT></B> Word8Vector: MLTON_MONO_VECTOR <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"> Word8Vector.vector
                                               </FONT></B><B><FONT COLOR="#0000FF">where</FONT></B> <B><FONT COLOR="#0000FF">type</FONT></B><B><FONT COLOR="#228B22"> elem </FONT></B>=<B><FONT COLOR="#228B22"> Word8Vector.elem
      </FONT></B><B><FONT COLOR="#0000FF">structure</FONT></B> World: MLTON_WORLD
   <B><FONT COLOR="#0000FF">end</FONT></B>
</PRE>
<p>
 
</p>
<h2 id="head-58b7888b27adca6d197bc42df58e8c0c70fe97d0">Substructures</h2>

    <ul>

    <li>
<p>
 <a href="MLtonArray">MLtonArray</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonBinIO">MLtonBinIO</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonCont">MLtonCont</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonExn">MLtonExn</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonFinalizable">MLtonFinalizable</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonGC">MLtonGC</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonIntInf">MLtonIntInf</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonIO">MLtonIO</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonItimer">MLtonItimer</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonMonoArray">MLtonMonoArray</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonMonoVector">MLtonMonoVector</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonPlatform">MLtonPlatform</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonPointer">MLtonPointer</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonProcEnv">MLtonProcEnv</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonProcess">MLtonProcess</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonRandom">MLtonRandom</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonReal">MLtonReal</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonRlimit">MLtonRlimit</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonRusage">MLtonRusage</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonSignal">MLtonSignal</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonSocket">MLtonSocket</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonSyslog">MLtonSyslog</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonTextIO">MLtonTextIO</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonThread">MLtonThread</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonVector">MLtonVector</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonWeak">MLtonWeak</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonWord">MLtonWord</a> 
</p>
</li>
    <li>
<p>
 <a href="MLtonWorld">MLtonWorld</a> 
</p>
</li>

    </ul>


<h2 id="head-b1564f6b1512cbfa3cfcebc9a5badb6b239954f1">Values</h2>

    <ul>

    <li>
<p>
 <tt>eq&nbsp;(x,&nbsp;y)</tt>  <br>
returns true if <tt>x</tt> and <tt>y</tt> are equal as pointers.  For  simple types like <tt>char</tt>, <tt>int</tt>, and <tt>word</tt>, this is the  same as equals.  For arrays, datatypes, strings, tuples, and vectors,  this is a simple pointer equality.  The semantics is a bit murky. 
</p>
</li>
    <li class="gap">
<p>
 <tt>equal&nbsp;(x,&nbsp;y)</tt>  <br>
returns true if <tt>x</tt> and <tt>y</tt> are structurally equal.  For equality types, this is the same as <a href="PolymorphicEquality">PolymorphicEquality</a>.  For other types, it is a conservative approximation of equivalence. 
</p>
</li>
    <li class="gap">
<p>
 <tt>hash&nbsp;x</tt>  <br>
returns a structural hash of <tt>x</tt>.  The hash function is consistent between execution of the same program, but may not be consistent between different programs. 
</p>
</li>
    <li class="gap">
<p>
 <tt>isMLton</tt>  <br>
is always true in a MLton implementation, and is always false in a  stub implementation. 
</p>
</li>
    <li class="gap">
<p>
 <tt>share&nbsp;x</tt>  <br>
maximizes sharing in the heap for the object graph reachable from  <tt>x</tt>. 
</p>
</li>
    <li class="gap">
<p>
 <tt>shareAll&nbsp;()</tt>  <br>
maximizes sharing in the heap by sharing space for equivalent  immutable objects.  A call to <tt>shareAll</tt> performs a major garbage  collection, and takes time proportional to the size of the heap. 
</p>
</li>
    <li class="gap">
<p>
 <tt>size&nbsp;x</tt>  <br>
returns the amount of heap space (in bytes) taken by the value of  <tt>x</tt>, including all objects reachable from <tt>x</tt> by following  pointers.  It takes time proportional to the size of <tt>x</tt>.  See  below for an example. 
</p>
</li>

    </ul>


<h2 id="head-48c21e9f702d3a4e4ebc0ce38e1d6c7f6bf73f5b">Example of MLton.size</h2>
<a id="size"></a> <p>
This example, <tt>size.sml</tt>, demonstrates the application of <tt>MLton.size</tt> to many different kinds of objects. 
</p>

<pre class=code>
<B><FONT COLOR="#A020F0">fun</FONT></B> <B><FONT COLOR="#228B22">'a</FONT></B> printSize (name: string, min: int, value: 'a): unit=
   <B><FONT COLOR="#A020F0">if</FONT></B> MLton.size value &gt;= min
      <B><FONT COLOR="#A020F0">then</FONT></B>
         (print <B><FONT COLOR="#BC8F8F">&quot;The size of &quot;</FONT></B>
          ; print name
          ; print <B><FONT COLOR="#BC8F8F">&quot; is &gt;= &quot;</FONT></B>
          ; print (Int.toString min)
          ; print <B><FONT COLOR="#BC8F8F">&quot; bytes.\n&quot;</FONT></B>)
   <B><FONT COLOR="#A020F0">else</FONT></B> ()

<B><FONT COLOR="#A020F0">val</FONT></B> l = [<B><FONT COLOR="#5F9EA0">1</FONT></B>, <B><FONT COLOR="#5F9EA0">2</FONT></B>, <B><FONT COLOR="#5F9EA0">3</FONT></B>, <B><FONT COLOR="#5F9EA0">4</FONT></B>]

<B><FONT COLOR="#A020F0">val</FONT></B> _ =
   (
    printSize (<B><FONT COLOR="#BC8F8F">&quot;a char&quot;</FONT></B>, <B><FONT COLOR="#5F9EA0">0</FONT></B>, #<B><FONT COLOR="#BC8F8F">&quot;c&quot;</FONT></B>)
    ; printSize (<B><FONT COLOR="#BC8F8F">&quot;an int list of length 4&quot;</FONT></B>, <B><FONT COLOR="#5F9EA0">48</FONT></B>, l)
    ; printSize (<B><FONT COLOR="#BC8F8F">&quot;a string of length 10&quot;</FONT></B>, <B><FONT COLOR="#5F9EA0">24</FONT></B>, <B><FONT COLOR="#BC8F8F">&quot;0123456789&quot;</FONT></B>)
    ; printSize (<B><FONT COLOR="#BC8F8F">&quot;an int array of length 10&quot;</FONT></B>, <B><FONT COLOR="#5F9EA0">52</FONT></B>, Array.tabulate (<B><FONT COLOR="#5F9EA0">10</FONT></B>, <B><FONT COLOR="#A020F0">fn</FONT></B> _ =&gt; <B><FONT COLOR="#5F9EA0">0</FONT></B>))
    ; printSize (<B><FONT COLOR="#BC8F8F">&quot;a double array of length 10&quot;</FONT></B>,
                 <B><FONT COLOR="#5F9EA0">92</FONT></B>, Array.tabulate (<B><FONT COLOR="#5F9EA0">10</FONT></B>, <B><FONT COLOR="#A020F0">fn</FONT></B> _ =&gt; <B><FONT COLOR="#5F9EA0">0.0</FONT></B>))
    ; printSize (<B><FONT COLOR="#BC8F8F">&quot;an array of length 10 of 2-ples of ints&quot;</FONT></B>,
                 <B><FONT COLOR="#5F9EA0">92</FONT></B>, Array.tabulate (<B><FONT COLOR="#5F9EA0">10</FONT></B>, <B><FONT COLOR="#A020F0">fn</FONT></B> i =&gt; (i, i + <B><FONT COLOR="#5F9EA0">1</FONT></B>)))
    ; printSize (<B><FONT COLOR="#BC8F8F">&quot;a useless function&quot;</FONT></B>, <B><FONT COLOR="#5F9EA0">0</FONT></B>, <B><FONT COLOR="#A020F0">fn</FONT></B> _ =&gt; <B><FONT COLOR="#5F9EA0">13</FONT></B>)
    )

<I><FONT COLOR="#B22222">(* This is here so that the list is &quot;useful&quot;.
 * If it were removed, then the optimizer (remove-unused-constructors)
 * would remove l entirely.
 *)</FONT></I>
<B><FONT COLOR="#A020F0">val</FONT></B> _ = <B><FONT COLOR="#A020F0">if</FONT></B> <B><FONT COLOR="#5F9EA0">10</FONT></B> = foldl (<B><FONT COLOR="#A020F0">op</FONT></B> +) <B><FONT COLOR="#5F9EA0">0</FONT></B> l
           <B><FONT COLOR="#A020F0">then</FONT></B> ()
        <B><FONT COLOR="#A020F0">else</FONT></B> <B><FONT COLOR="#A020F0">raise</FONT></B> Fail <B><FONT COLOR="#BC8F8F">&quot;bug&quot;</FONT></B>
   
<B><FONT COLOR="#0000FF">local</FONT></B>
   <B><FONT COLOR="#0000FF">open</FONT></B> MLton.Cont
<B><FONT COLOR="#0000FF">in</FONT></B>
   <B><FONT COLOR="#A020F0">val</FONT></B> rc: int option t option ref = ref NONE
   <B><FONT COLOR="#A020F0">val</FONT></B> _ =
      <B><FONT COLOR="#A020F0">case</FONT></B> callcc (<B><FONT COLOR="#A020F0">fn</FONT></B> k: int option t =&gt; (rc := SOME k; throw (k, NONE))) <B><FONT COLOR="#A020F0">of</FONT></B>
         NONE =&gt; ()
       | SOME i =&gt; print (concat [Int.toString i, <B><FONT COLOR="#BC8F8F">&quot;\n&quot;</FONT></B>])
<B><FONT COLOR="#0000FF">end</FONT></B>

<B><FONT COLOR="#A020F0">val</FONT></B> _ =
   (print <B><FONT COLOR="#BC8F8F">&quot;The size of a continuation option ref is &quot;</FONT></B>
    ; <B><FONT COLOR="#A020F0">if</FONT></B> MLton.size rc &gt; <B><FONT COLOR="#5F9EA0">1000</FONT></B>
         <B><FONT COLOR="#A020F0">then</FONT></B> print <B><FONT COLOR="#BC8F8F">&quot;&gt; 1000.\n&quot;</FONT></B>
      <B><FONT COLOR="#A020F0">else</FONT></B> print <B><FONT COLOR="#BC8F8F">&quot;&lt; 1000.\n&quot;</FONT></B>)

<B><FONT COLOR="#A020F0">val</FONT></B> _ =
   <B><FONT COLOR="#A020F0">case</FONT></B> !rc <B><FONT COLOR="#A020F0">of</FONT></B>
      NONE =&gt; ()
    | SOME k =&gt; (rc := NONE; MLton.Cont.throw (k, SOME <B><FONT COLOR="#5F9EA0">13</FONT></B>))
</PRE>
<p>
 
</p>
<p>
Compile and run as usual. 
<pre>% mlton size.sml
% ./size
The size of a char is &gt;= 0 bytes.
The size of an int list of length 4 is &gt;= 48 bytes.
The size of a string of length 10 is &gt;= 24 bytes.
The size of an int array of length 10 is &gt;= 52 bytes.
The size of a double array of length 10 is &gt;= 92 bytes.
The size of an array of length 10 of 2-ples of ints is &gt;= 92 bytes.
The size of a useless function is &gt;= 0 bytes.
The size of a continuation option ref is &gt; 1000.
13
The size of a continuation option ref is &lt; 1000.
</pre>
</p>
</div>



<p>
<hr>
Last edited on 2009-06-06 01:21:46 by <span title="c-67-165-143-160.hsd1.il.comcast.net"><a href="MatthewFluet">MatthewFluet</a></span>.
</body></html>