MLton 20070826 MLtonWeak
Home  Index  
signature MLTON_WEAK =
   sig
      type 'a t

      val get: 'a t -> 'a option
      val new: 'a -> 'a t
   end

A weak pointer is a pointer to an object that is nulled if the object becomes unreachable due to garbage collection. The weak pointer does not itself cause the object it points to be retained by the garbage collector -- only other strong pointers can do that. For objects that are not allocated in the heap, like integers, a weak pointer will always be nulled. So, if w: int Weak.t then Weak.get w = NONE.


Last edited on 2007-08-23 03:45:54 by MatthewFluet.