Ocamljs uses the
ocamlc front-end up to the point where it generates ‘lambda’ code–an untyped representation that looks a lot like Lisp. (You can see the lambda representation of OCaml code with the -dlambda option to
This apply method is also where tail-recursion is implemented, using trampolines. See
src/stdlib/support.js for details.
src/ocamljs/primitives.js. Some OCaml primitives are implemented directly by the code generator; see
src/stdlib/support.js for functions on blocks.
Ocamljs has two string representations: Mutable strings are arrays of chars (represented as numbers) with a
Buffer.contents (and therefore
Printf.sprintf) yield immutable strings. But
String.create returns a mutable string. You can read the elements of either string as usual, but writing to an immutable string fails (at present with an inscrutable error). If you call native code with a mutable string it may or may not do the right thing. (XXX maybe it would be better to drop support for immutable strings entirely.)