1 fun 'a
printSize (name
: string, min
: int, value
: 'a
): unit
=
2 if MLton
.size value
>= min
7 ; print (Int.toString min
)
15 printSize ("a char", 0, #
"c")
16 ; printSize ("an int list of length 4", 48, l
)
17 ; printSize ("a string of length 10", 24, "0123456789")
18 ; printSize ("an int array of length 10", 52, Array
.tabulate (10, fn _
=> 0))
19 ; printSize ("a double array of length 10",
20 92, Array
.tabulate (10, fn _
=> 0.0))
21 ; printSize ("an array of length 10 of 2-ples of ints",
22 92, Array
.tabulate (10, fn i
=> (i
, i
+ 1)))
23 ; printSize ("a useless function", 0, fn _
=> 13)
26 (* This is here so that the list is
"useful".
27 * If it were removed
, then the
optimizer (remove
-unused
-constructors
)
28 * would remove l entirely
.
30 val _
= if 10 = foldl (op +) 0 l
37 val rc
: int option t option ref
= ref NONE
39 case callcc (fn k
: int option t
=> (rc
:= SOME k
; throw (k
, NONE
))) of
41 | SOME i
=> print (concat
[Int.toString i
, "\n"])
45 (print
"The size of a continuation option ref is "
46 ; if MLton
.size rc
> 1000
47 then print
"> 1000.\n"
48 else print
"< 1000.\n")
53 | SOME k
=> (rc
:= NONE
; MLton
.Cont
.throw (k
, SOME
13))