Oo(3)
β¨ Oo(3) β¨ β OCaml library, bestie π
okay so this is the <pink>Oo</pink> page from the OCaml library manual, and it's literally all about Operations on objects π. it's short, it's iconic, and honestly it ate.
πΈ NAME πΈ
Oo β operations on objects π«Ά
π¦ Module π¦
Module Oo β¨
no cap, that's the whole module line. she's minimal, she's mysterious, she's giving main character energy.
π Documentation π
Module Oo
: sig end
so yeah β the module is Oo, and its signature lives between that sig and that end π. cute little self-contained vibe.
Operations on objects β that's the whole tagline, and honestly? slay.
β val copy : (< .. > as 'a) -> 'a
Oo.copy o returns a copy of object o β and by "copy" we mean a fresh object with the same methods and instance variables as o π
. same fit, new body, iykyk.
β οΈ Alert unsynchronized_access. Unsynchronized accesses to mutable objects are a programming error. fr fr, do not come crying to me after you race two threads on the same mutable object π β that's on you, bestie.
π₯ val id : < .. > -> int
returns an integer identifying this object, and it's unique for the current execution of the program π. it's basically the object's government name for this run only.
the generic comparison and hashing functions are based on this integer. so like, everything downstream leans on id β keep that in mind π§ β¨.
and here's the tea π: when an object is obtained by unmarshaling, the id is refreshed, so it's different from the original object's id. as a consequence, the internal invariants of data structures such as hash table or sets containing objects are broken after unmarshaling the data structures ππ.
big warning energy: unmarshal an object that's sitting inside a hash table or a set and the invariants are toast. not me finding out the hard way. π
that's it, that's the page β short but she served π. this was OCamldoc, dated 2026-06-22, footer Oo(3), and yes the doc said OCamldoc so we're crediting OCamldoc periodt πβ¨. mwah, go write some objects π
π¦ 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