Stdlib.Oo(3)

hiii bestie πŸ’– welcome to the Stdlib.Oo(3) page, which lives in the OCaml library. This one is short and iconic, so let's get into it. ✨

🌸 NAME 🌸

Stdlib.Oo - no description 😭. That's literally what the manpage says, bestie. We move.


πŸŽ€ Module πŸŽ€

The module line is:

Module   Stdlib.Oo

That's the whole section. Slay. πŸ’…

πŸ’– Documentation πŸ’–

Under documentation, it's the Oo module, wired up like this:

Module Oo
 : (module Stdlib__Oo)

πŸ¦‹ copy πŸ¦‹

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. No cap, it's giving duplicate-but-make-it-fresh. ✨

⚠️ Alert unsynchronized_access. Unsynchronized accesses to mutable objects are a programming error. This is a real warning, bestie β€” don't let unsynchronized access catch you slipping. πŸ’€

🌈 id 🌈

val id : < .. > -> int

id returns an integer identifying this object, unique for the current execution of the program. The generic comparison and hashing functions are based on this integer. πŸ‘‘

But here's the plot twist 😭: when an object is obtained by unmarshaling, the id is refreshed, and thus different from the original object. As a consequence, the internal invariants of data structures such as hash table or sets containing objects are broken after unmarshaling the data structures. That's a major "protect your invariants" moment, fr fr. 🫢


mwah πŸ’‹ this page was brought to you by the footer energy: source/version OCamldoc, date 2026-06-22, and the page name Stdlib.Oo(3). periodt. πŸŽ€

πŸ“¦ where this page comes from