back
2 comments
Yikes. The writer should probably learn about "noalloc", else those calls to C are going to be very slow. Also he should have a look at the Bigarray module and the implementation of the ocaml-bitstring primitives.

http://camltastic.blogspot.co.uk/2008/08/tip-calling-c-funct...

https://code.google.com/p/bitstring/

Edit: I'm also dubious about the purpose of this exercise. What's wrong with binding an existing C library? The C library likely represents man-years of work (I know HTTP/2 is new, but still), and will be far less buggy than anything you can write in OCaml in a reasonable time, and those benefits keep on accruing to the C implementation in future. And OCaml makes it real easy to write efficient bindings to C, including direct calls - see link above - and manipulating C pointers directly.

So that overflow example, is undefined behaviour. Probably not a great thing to introduce into OCaml types.