Stdlib.Obj(3) OCaml library Stdlib.Obj(3)

# [NAME](#NAME)

Stdlib.Obj - no description

# [Module](#Module)

Module Stdlib.Obj

# [Documentation](#Documentation)

Module **Obj**  
: **(module Stdlib\_\_Obj)**

*type t*

*type raw\_data* = **nativeint**

*val repr* : **'a -&gt; t**

*val obj* : **t -&gt; 'a**

*val magic* : **'a -&gt; 'b**

*val is\_block* : **t -&gt; bool**

*val is\_int* : **t -&gt; bool**

*val tag* : **t -&gt; int**

*val size* : **t -&gt; int**

*val reachable\_words* : **t -&gt; int**

Computes the total size (in words, including the headers) of all heap blocks accessible from the argument. Statically allocated blocks are excluded, unless the runtime system was configured with **--disable-naked-pointers** .

**Since** 4.04

*val field* : **t -&gt; int -&gt; t**

*val set\_field* : **t -&gt; int -&gt; t -&gt; unit**

When using flambda:

**set\_field** MUST NOT be called on immutable blocks. (Blocks allocated in C stubs, or with **new\_block** below, are always considered mutable.)

The same goes for **set\_double\_field** and **set\_tag** . However, for **set\_tag** , in the case of immutable blocks where the middle-end optimizers never see code that discriminates on their tag (for example records), the operation should be safe. Such uses are nonetheless discouraged.

For experts only: **set\_field** et al can be made safe by first wrapping the block in **Sys.opaque\_identity** , so any information about its contents will not be propagated.

*val set\_tag* : **t -&gt; int -&gt; unit**

*val double\_field* : **t -&gt; int -&gt; float**

*val set\_double\_field* : **t -&gt; int -&gt; float -&gt; unit**

*val raw\_field* : **t -&gt; int -&gt; raw\_data**

*val set\_raw\_field* : **t -&gt; int -&gt; raw\_data -&gt; unit**

*val new\_block* : **int -&gt; int -&gt; t**

*val dup* : **t -&gt; t**

*val truncate* : **t -&gt; int -&gt; unit**

*val add\_offset* : **t -&gt; Int32.t -&gt; t**

*val with\_tag* : **int -&gt; t -&gt; t**

*val first\_non\_constant\_constructor\_tag* : **int**

*val last\_non\_constant\_constructor\_tag* : **int**

*val lazy\_tag* : **int**

*val closure\_tag* : **int**

*val object\_tag* : **int**

*val infix\_tag* : **int**

*val forward\_tag* : **int**

*val no\_scan\_tag* : **int**

*val abstract\_tag* : **int**

*val string\_tag* : **int**

*val double\_tag* : **int**

*val double\_array\_tag* : **int**

*val custom\_tag* : **int**

*val final\_tag* : **int**

*val int\_tag* : **int**

*val out\_of\_heap\_tag* : **int**

*val unaligned\_tag* : **int**

*module Closure :* **sig end**

*module Extension\_constructor :* **sig end**

*val extension\_constructor* : **'a -&gt; extension\_constructor**

*val extension\_name* : **extension\_constructor -&gt; string**

*val extension\_id* : **extension\_constructor -&gt; int**

*module Ephemeron :* **sig end**

2026-10-27 OCamldoc

---

Document: Stdlib.Obj(3o) from ocaml-4 4.14.4-r4 (Chainguard OS)
Source: https://github.com/ocaml/ocaml
