0

I'm new to OCaml, and I'm trying to follow 4.3 of this tutorial for defining custom quotation behavior. From what I've read, it seems that loading camlp4o.cma is what makes the Quotation module visible to OCaml. So I tried the following in the OCaml interpreter:

# #load "dynlink.cma";;
# #load "camlp4o.cma";;
        Camlp4 Parsing version 4.02.3

It looks like camlp4o.cma was loaded successfully. So I continued with the rest of the tutorial:

# let expand _ s =
           match s with
             "PI" -> "3.14159"
           | "goban" -> "19*19"
           | "chess" -> "8*8"
           | "ZERO" -> "0"
           | "ONE" -> "1"
           | _ -> "\"" ^ s ^ "\""
         ;;
val expand : 'a -> string -> string = <fun>
# Quotation.add "foo" (Quotation.ExStr expand);;
Characters 0-13:
  Quotation.add "foo" (Quotation.ExStr expand);;
  ^^^^^^^^^^^^^
Error: Unbound module Quotation

I'm not sure why I'm getting this error. Did I skip something? I'm using OCaml version 4.02.3 on Windows, if that's relevant.

user287393
  • 1,221
  • 8
  • 13

1 Answers1

1

The tutorial under http://caml.inria.fr/pub/docs/tutorial-camlp4/index.html is OLD. It is based on CamlP4 before version 3.10.0. CamlP4 was rewritten completely at OCaml 3.10.0. This "new" CamlP4 has lots of incompatibilities.

Nowadays people have already moved from CamlP4 to PPX, so I am not sure CamlP4 is worth learning. Being said, you can see https://github.com/ocaml/camlp4/wiki for some documentations of the "new" CamlP4. Jake Donham's blog http://ambassadortothecomputers.blogspot.com/ also provides good information about it.

camlspotter
  • 8,990
  • 23
  • 27