123456789101112131415161718192021(** Why allocate a ref instead of storing the int directly?
We generate many more sexp grammars than actually get used, so we prefer to defer the
id until we need it. The compiler can optimize away allocations that nobody touches.
*)typet=intLazy.tletcreate=letnext=ref0infun()->lazy((* As long as we don't give up the global Ocaml runtime lock by allocating, we can
treat the read and write as atomic. See "20.12.2 Parallel execution of long-running
C code" in the 4.09 manual. *)letid=!nextinnext:=id+1;id)letforce(t:t)=Lazy.forcetletcompareab=compare(forcea)(forceb)