That is a function that takes two arguments. On the C side, I would call that with caml_callback2(*caml_named_value("cbf_coh_insert"), k, v);. Is there a way, on the C side, to check that the number of arguments (2 in this case) match? Other than I guess calling it and trying to trap a SIGSEGV. Thanks!

I want to guard against the possibility of accidentally registering an update callback function (which has 3 arguments, key, old value and new value, and I call in the C with caml_callback3) as an insert, for example. Or delete which has only 1, the key.
–
GaiusAug 8 '11 at 13:47

I intend to supply the C bit as a "black box" that the OCaml user will not need to touch.
–
GaiusAug 8 '11 at 13:51

3

make special ocaml functions for registering callbacks with proper types
–
ygrekAug 8 '11 at 14:05

I thought of that, but remember that we have the function name as a string literal. The OCaml compiler can't "see" the assocation between the content of that string, and the actual name of a function in the code, you could register any function under any name.
–
GaiusAug 8 '11 at 15:33