[MLton-commit] r6067

Vesa Karvonen vesak at mlton.org
Thu Oct 11 05:49:55 PDT 2007


Instantiate dummy values lazily.  This is necessary with recursive types.
----------------------------------------------------------------------

U   mltonlib/trunk/com/ssh/generic/unstable/detail/value/pickle.sml

----------------------------------------------------------------------

Modified: mltonlib/trunk/com/ssh/generic/unstable/detail/value/pickle.sml
===================================================================
--- mltonlib/trunk/com/ssh/generic/unstable/detail/value/pickle.sml	2007-10-09 23:24:45 UTC (rev 6066)
+++ mltonlib/trunk/com/ssh/generic/unstable/detail/value/pickle.sml	2007-10-11 12:49:54 UTC (rev 6067)
@@ -565,7 +565,11 @@
          val self = Arg.Open.refc ignore aT
       in
          if Arg.mayBeCyclic self
-         then cyclic {readProxy = I.thunk (ref o const (Arg.some aT)),
+         then cyclic {readProxy = let
+                         val dummy = delay (fn () => Arg.some aT)
+                      in
+                         I.thunk (fn _ => ref (force dummy))
+                      end,
                       readBody = fn proxy => I.map (fn v => proxy := v) rd,
                       writeWhole = wr o !,
                       self = self}
@@ -575,7 +579,12 @@
       fun array aT = let
          val P {rd = aR, wr = aW, ...} = getT aT
       in
-         mutable {readProxy = I.map (Array.array /> Arg.some aT) (rd size),
+         mutable {readProxy = let
+                     val dummy = delay (fn () => Arg.some aT)
+                  in
+                     I.map (fn n => (Array.array (n, force dummy)))
+                           (rd size)
+                  end,
                   readBody = fn a => let
                      open I
                      fun lp i = if i = Array.length a




More information about the MLton-commit mailing list