Closed ziman closed 4 years ago
I'm afraid there's not a huge amount of docs on the guts of the compiler, so reading and grepping is the best option at the moment. (There are a few HACKING.adoc files in the OCaml sources that might be helpful).
So for the record, the answer is that we actually don't want to add more primitives because:
The correct way is to use just the provided Malfunction primitives (such as byte arrays, or arrays, even for strings) and if functions in the stdlib require adding OCaml primitives, they need to be reimplemented on the side.
Is there any documentation on how to add primitives to Malfunction so that we can use the OCaml standard library? Currently, I'm reading (and grepping) the sources of the OCaml compiler, the stdlib, and Malfunction, and slowly trying to figure out how everything works. Some primitives seem to be implemented as C functions; some seem to be builtins.
I tried copy-pasting bits and pieces around and editing them, which made the compiler stop complaining about some unimplemented primitives such as
%string_length
(and start complaining about the next one), but don't know if it will work once it eventually compiles.Is there any recommended reference to look at?