Most of the primitives from the standard library are already implemented and loaded by default (located in "runtime.js").
Additionally, some other primitives are installed but not loaded by default:
- "+toplevel.js" : when compiling toplevel
js_of_ocaml jsfile.js a.byte
Or load it from a findlib package
js_of_ocaml +mypackage/jsfile.js a.byte
The file jsfile.js will be looked up inside mypackage lib directory. When no package is provided, the compiler will look inside js_of_ocaml-compiler lib directory.
- //Provides is used to declare a primitive; an annotation
can be used to specify the possible side-effects of the primitive:
- const means no side-effect; mutable indicates that the primitive has no side-effect but that other primitives might affect the returned value of the primitive; when no annotation is provided, the linker assumes that the primitive may have side-effects.
- //Requires is used if other primitives need to be loaded first
- version_constraint looks like "< 4.02.1"