Callback(3)
π Callback(3) β like, the OCaml library one, bestie π
okay so this is <rainbow>Callback</rainbow> from the OCaml library man pages, and honestly? it's giving backstage-pass energy for your C code. stay with me π«Ά
β¨ NAME β¨
Callback β registering OCaml values with the C runtime</p>. that's the whole vibe. no cap.
π Module π
the module is literally called Module Callback. yes bestie, that's the name, we don't question it π
πΈ Documentation πΈ
so the signature is just:
Module Callback
: sig end
and the one-line summary is, again, registering OCaml values with the C runtime. (they really said "say it twice, it's important" and honestly? iconic.)
here's the tea π: this module lets OCaml values get registered with the C runtime under a symbolic name, so that later on, your C code can call back registered OCaml functions, or raise registered OCaml exceptions. it's literally the group chat bridge between OCaml and C. iykyk π₯
π the functions π
val register : string -> 'a -> unit
Callback.register n v registers the value v under the name n. later, C code can retrieve a handle to v by calling caml_named_value(n). that's it, that's the whole slay β¨
val register_exception : string -> exn -> unit
Callback.register_exception n exn registers the exception contained in the exception value exn under the name n. later, C code can retrieve a handle to that exception by calling caml_named_value(n). and the exception value you get back this way is suitable for passing as the first argument to raise_constant or raise_with_arg. cute, functional, no notes π§
lowkey reminder bestie: caml_named_value(n) is the retrieval function in both cases, and the names you register under are the keys C uses to find your stuff. don't lose the name, or C is gonna be standing there like π
and that's the page!! π¦ written by OCamldoc, dated 2026-06-22, and it's the Callback(3) page β go forth and register your values, bestie, you're the main character of the FFI now ππ
π¦ where this page comes from
- arch rolling: ocaml 5.5.0-1 Β· LGPL2.1 AND custom: QPL-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms