Obj(3)
β¨ NAME β¨
okay so bestie, this is Obj from the OCaml library manual, section 3 β Operations on internal representations of values. It's lowkey giving "expert internals only" energy, and the page literally says Not for the casual user. π
π§ Module π§
Module Obj
π Documentation π
Module Obj : sig end
Operations on internal representations of values.
Not for the casual user. No cap, this is advanced internals territory. π«Ά
πΈ Types πΈ
type ttype raw_data = nativeint
π Values and functions π
here's the signature stack, exactly as written β the page doesn't add extra descriptions for most of these, so I'm not inventing lore:
val repr : 'a -> tval obj : t -> 'aval magic : 'a -> 'bval is_block : t -> boolval is_int : t -> boolval tag : t -> intval size : t -> intval reachable_words : t -> intβ Computes the total size (in words, including the headers) of all heap blocks accessible from the argument. Statically allocated blocks are included. Since 4.04 β¨val field : t -> int -> tval set_field : t -> int -> t -> unit
When using flambda:set_fieldMUST NOT be called on immutable blocks. (Blocks allocated in C stubs, or withnew_blockbelow, are always considered mutable.) The same goes forset_double_field. For experts only:set_fieldet al can be made safe by first wrapping the block inSys.opaque_identity, so any information about its contents will not be propagated.
val double_field : t -> int -> floatval set_double_field : t -> int -> float -> unitval raw_field : t -> int -> raw_dataval set_raw_field : t -> int -> raw_data -> unitval new_block : int -> int -> tval dup : t -> tval add_offset : t -> Int32.t -> tval with_tag : int -> t -> t
π Tag constants π
all int constants, in exact page order:
val first_non_constant_constructor_tag : intval last_non_constant_constructor_tag : intval forcing_tag : intval cont_tag : intval lazy_tag : intval closure_tag : intval object_tag : intval infix_tag : intval forward_tag : intval no_scan_tag : intval abstract_tag : intval string_tag : intval double_tag : intval double_array_tag : intval custom_tag : intval int_tag : intval out_of_heap_tag : intval unaligned_tag : int
π¦ Submodules π¦
module Extension_constructor : sig endmodule Ephemeron : sig end
okay that's the whole Obj(3) page, bestie. This rewrite is sourced from OCamldoc, dated 2026-06-22, for Obj(3) β go be iconic with your internals, but maybe don't @ me if you crash the runtime πβ¨
π¦ 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