[MLton-commit] r5727

Vesa Karvonen vesak at mlton.org
Wed Jul 4 03:49:05 PDT 2007


Naive implementation for SML/NJ.
----------------------------------------------------------------------

U   mltonlib/trunk/com/ssh/random/unstable/detail/ml/smlnj/random-dev.sml

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

Modified: mltonlib/trunk/com/ssh/random/unstable/detail/ml/smlnj/random-dev.sml
===================================================================
--- mltonlib/trunk/com/ssh/random/unstable/detail/ml/smlnj/random-dev.sml	2007-07-04 10:19:14 UTC (rev 5726)
+++ mltonlib/trunk/com/ssh/random/unstable/detail/ml/smlnj/random-dev.sml	2007-07-04 10:49:03 UTC (rev 5727)
@@ -5,7 +5,14 @@
  *)
 
 structure RandomDev : RANDOM_DEV = struct
-   (* XXX implement reasonable seed/useed for SML/NJ *)
-   fun seed () = raise Fail "not implemented"
+   (* XXX implement better seed/useed for SML/NJ *)
+   val cnt = ref 0w0
+   fun seed () =
+       SOME (Word.xorb
+                (Word.fromLargeInt
+                    (Time.toNanoseconds (Time.now ()) mod
+                     Word.toLargeInt Word.maxValue),
+                 !cnt)
+             before cnt := !cnt + 0w1)
    val useed = seed
 end




More information about the MLton-commit mailing list