1Obj(3) OCaml library Obj(3)
2
3
4
6 Obj - Operations on internal representations of values.
7
9 Module Obj
10
12 Module Obj
13 : sig end
14
15
16 Operations on internal representations of values.
17
18 Not for the casual user.
19
20
21
22
23
24 type t
25
26
27
28
29
30 val repr : 'a -> t
31
32
33
34
35 val obj : t -> 'a
36
37
38
39
40 val magic : 'a -> 'b
41
42
43
44
45 val is_block : t -> bool
46
47
48
49
50 val is_int : t -> bool
51
52
53
54
55 val tag : t -> int
56
57
58
59
60 val size : t -> int
61
62
63
64
65 val reachable_words : t -> int
66
67 Computes the total size (in words, including the headers) of all heap
68 blocks accessible from the argument. Statically allocated blocks are
69 excluded.
70
71 @Since 4.04
72
73
74
75 val field : t -> int -> t
76
77
78
79
80 val set_field : t -> int -> t -> unit
81
82 When using flambda:
83
84
85 set_field MUST NOT be called on immutable blocks. (Blocks allocated in
86 C stubs, or with new_block below, are always considered mutable.)
87
88 The same goes for set_double_field and set_tag . However, for set_tag
89 , in the case of immutable blocks where the middle-end optimizers never
90 see code that discriminates on their tag (for example records), the
91 operation should be safe. Such uses are nonetheless discouraged.
92
93 For experts only: set_field et al can be made safe by first wrapping
94 the block in Sys.opaque_identity , so any information about its con‐
95 tents will not be propagated.
96
97
98
99 val set_tag : t -> int -> unit
100
101
102
103
104 val double_field : t -> int -> float
105
106
107
108
109 val set_double_field : t -> int -> float -> unit
110
111
112
113
114 val new_block : int -> int -> t
115
116
117
118
119 val dup : t -> t
120
121
122
123
124 val truncate : t -> int -> unit
125
126
127
128
129 val add_offset : t -> Int32.t -> t
130
131
132
133
134 val first_non_constant_constructor_tag : int
135
136
137
138
139 val last_non_constant_constructor_tag : int
140
141
142
143
144 val lazy_tag : int
145
146
147
148
149 val closure_tag : int
150
151
152
153
154 val object_tag : int
155
156
157
158
159 val infix_tag : int
160
161
162
163
164 val forward_tag : int
165
166
167
168
169 val no_scan_tag : int
170
171
172
173
174 val abstract_tag : int
175
176
177
178
179 val string_tag : int
180
181
182
183
184 val double_tag : int
185
186
187
188
189 val double_array_tag : int
190
191
192
193
194 val custom_tag : int
195
196
197
198
199 val final_tag : int
200
201
202
203
204 val int_tag : int
205
206
207
208
209 val out_of_heap_tag : int
210
211
212
213
214 val unaligned_tag : int
215
216
217
218
219 val extension_constructor : 'a -> extension_constructor
220
221
222
223
224 val extension_name : extension_constructor -> string
225
226
227
228
229 val extension_id : extension_constructor -> int
230
231
232
233
234
235 === The following two functions are deprecated. Use module Marshal
236 instead. ===
237
238
239 val marshal : t -> bytes
240
241
242
243
244 val unmarshal : bytes -> int -> t * int
245
246
247
248 module Ephemeron : sig end
249
250
251
252
253
254
255
256OCamldoc 2018-07-14 Obj(3)