[
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: | Jon Harrop <jon@f...> |
| Subject: | Re: [Caml-list] let rec and polymorphic functions |
There are many problems with this. Google for ad-hoc polymorphism, polymorphic recursion and generic printing. On Wednesday 27 June 2007 09:40:31 David Allsopp wrote: > out "TEST"; val out : string -> unit > out "%d" 0; val out : format -> int -> unit As printf is ad-hoc polymorphic, you must supply the format specifier immediately and OCaml will generate a custom printer for you. OCaml does not use run-time types so you cannot have a generic print function: you must specific print functions for each of your (possibly higher-order) types. Also, recursive calls ossify the function to a monomorphic type, so you cannot do polymorphic recursion in OCaml. There are workaround using recursive modules or objects but I don't think this is what you want here. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. The OCaml Journal http://www.ffconsultancy.com/products/ocaml_journal/?e