In ocaml toplevel (version 3.11.2) this simple expression gives me an error:
# let a = [] in if null a then 0 else 1;; Error: Unbound value null
I just started learning ocaml from an oreilly book , which apparently often uses null as a keyword - for example, at the top of page 32
# let rec size a_list = if null a_list then 0 else 1 + (size (List.tl a_list));;
I am embarrassed to ask such an obvious question. But after a long search, I came up empty-handed. Therefore, I am as open to suggestions from a Google query as to simple answers. (Google failed attempts: [ocaml "Error: Unbound value null"] [ocaml null keyword] [ocaml changelog null] [ocaml change null]).
Question: was null the ocaml keyword, but no more? Or did I install ocaml incorrectly or didn’t notice something?
I can, of course, replace every occurrence of "null" with "[]" in the code, but I am surprised that a verbatim copy of the code from the book gives me such an error so early. Is this book full of other mistakes? I believe this was written with ocaml 2.04 in mind; is it too old? I chose it because I liked the TOC and the free availability on the Internet. Besides this zero error (which I’m still ready to blame for myself than the authors have), the explanations are good, and I look forward to discussing a mixture of a functional and imperative style (reason for me, as someone only familiar with c / C ++ )
source share