Browse thread
beginner question: DAGs w/ recursive types an encapsulation of a Map
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Alain Frisch <Alain.Frisch@i...> |
| Subject: | Re: [Caml-list] beginner question: DAGs w/ recursive types an encapsulation of a Map |
Jon Harrop wrote: > # type tree' = int * (char * tree') list ;; > type tree' = int * (char * tree') list > > This is not "unsafe" in the usual sense of the word but it means that the > compiler will be less friendly on all of the rest of your code. The declaration is not "unsafe" by itself, but the -rectypes option is, in the sense that it will make the compiler accept programs that will produce infinite loops in the run-time system: http://caml.inria.fr/pub/docs/manual-ocaml/libref/Lazy.html << Note: if the program is compiled with the -rectypes option, ill-founded recursive definitions of the form let rec x = lazy x or let rec x = lazy(lazy(...(lazy x))) are accepted by the type-checker and lead, when forced, to ill-formed values that trigger infinite loops in the garbage collector and other parts of the run-time system. Without the -rectypes option, such ill-founded recursive definitions are rejected by the type-checker. >> (One might argue that the type checker does not reject non-terminating programs anyway.) -- Alain