ocamljs-of-ocaml

What does "##" after variable mean?


Js.coerce_opt (Dom_html.document##getElementById id)

I'm new to OCaml, and I'm dealing with Js_of_Ocaml recently. I've seen code as above that includes two pounds after between variable and function. What do they mean?


Solution

  • Ordinary method calls for OCaml objects are written as obj#meth.

    In order to handle Js objects, js_of_ocaml adds a (ppx) syntax extension that uses obj##meth for invoking methods for Js objects: https://ocsigen.org/js_of_ocaml/4.0.0/manual/ppx .