1
<?xml version="1.0" encoding="latin1" ?>
2
<!DOCTYPE cref SYSTEM "cref.dtd">
9
<holder>Ericsson AB, All Rights Reserved</holder>
12
The contents of this file are subject to the Erlang Public License,
13
Version 1.1, (the "License"); you may not use this file except in
14
compliance with the License. You should have received a copy of the
15
Erlang Public License along with this software. If not, it can be
16
retrieved online at http://www.erlang.org/.
18
Software distributed under the License is distributed on an "AS IS"
19
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
20
the License for the specific language governing rights and limitations
23
The Initial Developer of the Original Code is Ericsson AB.
26
<title>erl_eterm</title>
27
<prepared>Torbjörn Törnkvist</prepared>
28
<responsible>Torbjörn Törnkvist</responsible>
30
<approved>Bjarne Däcker</approved>
31
<checked>Torbjörn Törnkvist</checked>
34
<file>erl_eterm.sgml</file>
37
<libsummary>Functions for Erlang Term Construction</libsummary>
39
<p>This module contains functions for creating and manipulating
41
<p>An Erlang term is represented by a C structure of type
42
<c><![CDATA[ETERM]]></c>. Applications should not reference any fields in this
43
structure directly, because it may be changed in future releases
44
to provide faster and more compact term storage. Instead,
45
applications should us the macros and functions provided. </p>
46
<p>The following macros each take a single ETERM pointer as an
47
argument. They return a non-zero value if the test is true, and 0
50
<tag><c><![CDATA[ERL_IS_INTEGER(t)]]></c></tag>
51
<item>True if <c><![CDATA[t]]></c> is an integer.</item>
52
<tag><c><![CDATA[ERL_IS_UNSIGNED_INTEGER(t)]]></c></tag>
53
<item>True if <c><![CDATA[t]]></c> is an integer.</item>
54
<tag><c><![CDATA[ERL_IS_FLOAT(t)]]></c></tag>
55
<item>True if <c><![CDATA[t]]></c> is a floating point number.</item>
56
<tag><c><![CDATA[ERL_IS_ATOM(t)]]></c></tag>
57
<item>True if <c><![CDATA[t]]></c> is an atom.</item>
58
<tag><c><![CDATA[ERL_IS_PID(t)]]></c></tag>
59
<item>True if <c><![CDATA[t]]></c> is a Pid (process identifier).</item>
60
<tag><c><![CDATA[ERL_IS_PORT(t)]]></c></tag>
61
<item>True if <c><![CDATA[t]]></c> is a port.</item>
62
<tag><c><![CDATA[ERL_IS_REF(t)]]></c></tag>
63
<item>True if <c><![CDATA[t]]></c> is a reference.</item>
64
<tag><c><![CDATA[ERL_IS_TUPLE(t)]]></c></tag>
65
<item>True if <c><![CDATA[t]]></c> is a tuple.</item>
66
<tag><c><![CDATA[ERL_IS_BINARY(t)]]></c></tag>
67
<item>True if <c><![CDATA[t]]></c> is a binary.</item>
68
<tag><c><![CDATA[ERL_IS_LIST(t)]]></c></tag>
69
<item>True if <c><![CDATA[t]]></c> is a list with zero or more elements.</item>
70
<tag><c><![CDATA[ERL_IS_EMPTY_LIST(t)]]></c></tag>
71
<item>True if <c><![CDATA[t]]></c> is an empty list.</item>
72
<tag><c><![CDATA[ERL_IS_CONS(t)]]></c></tag>
73
<item>True if <c><![CDATA[t]]></c> is a list with at least one element.</item>
75
<p>The following macros can be used for retrieving parts of Erlang
76
terms. None of these do any type checking; results are undefined
77
if you pass an ETERM* containing the wrong type. For example,
78
passing a tuple to ERL_ATOM_PTR() will likely result in garbage.
81
<tag><c><![CDATA[char *ERL_ATOM_PTR(t)]]></c></tag>
82
<item>A string representing atom <c><![CDATA[t]]></c>.
84
<tag><c><![CDATA[int ERL_ATOM_SIZE(t)]]></c></tag>
85
<item>The length (in characters) of atom t.</item>
86
<tag><c><![CDATA[void *ERL_BIN_PTR(t)]]></c></tag>
87
<item>A pointer to the contents of <c><![CDATA[t]]></c></item>
88
<tag><c><![CDATA[int ERL_BIN_SIZE(t)]]></c></tag>
89
<item>The length (in bytes) of binary object <c><![CDATA[t]]></c>.</item>
90
<tag><c><![CDATA[int ERL_INT_VALUE(t)]]></c></tag>
91
<item>The integer of <c><![CDATA[t]]></c>.</item>
92
<tag><c><![CDATA[unsigned int ERL_INT_UVALUE(t)]]></c></tag>
93
<item>The unsigned integer value of <c><![CDATA[t]]></c>.</item>
94
<tag><c><![CDATA[double ERL_FLOAT_VALUE(t)]]></c></tag>
95
<item>The floating point value of <c><![CDATA[t]]></c>.</item>
96
<tag><c><![CDATA[ETERM *ERL_PID_NODE(t)]]></c></tag>
97
<item>The Node in pid <c><![CDATA[t]]></c>.</item>
98
<tag><c><![CDATA[int ERL_PID_NUMBER(t)]]></c></tag>
99
<item>The sequence number in pid <c><![CDATA[t]]></c>.</item>
100
<tag><c><![CDATA[int ERL_PID_SERIAL(t)]]></c></tag>
101
<item>The serial number in pid <c><![CDATA[t]]></c>.</item>
102
<tag><c><![CDATA[int ERL_PID_CREATION(t)]]></c></tag>
103
<item>The creation number in pid <c><![CDATA[t]]></c>.</item>
104
<tag><c><![CDATA[int ERL_PORT_NUMBER(t)]]></c></tag>
105
<item>The sequence number in port <c><![CDATA[t]]></c>.</item>
106
<tag><c><![CDATA[int ERL_PORT_CREATION(t)]]></c></tag>
107
<item>The creation number in port <c><![CDATA[t]]></c>.</item>
108
<tag><c><![CDATA[ETERM *ERL_PORT_NODE(t)]]></c></tag>
109
<item>The node in port <c><![CDATA[t]]></c>.</item>
110
<tag><c><![CDATA[int ERL_REF_NUMBER(t)]]></c></tag>
111
<item>The first part of the reference number in ref <c><![CDATA[t]]></c>. Use
112
only for compatibility.</item>
113
<tag><c><![CDATA[int ERL_REF_NUMBERS(t)]]></c></tag>
114
<item>Pointer to the array of reference numbers in ref <c><![CDATA[t]]></c>.</item>
115
<tag><c><![CDATA[int ERL_REF_LEN(t)]]></c></tag>
116
<item>The number of used reference numbers in ref <c><![CDATA[t]]></c>.</item>
117
<tag><c><![CDATA[int ERL_REF_CREATION(t)]]></c></tag>
118
<item>The creation number in ref <c><![CDATA[t]]></c>.</item>
119
<tag><c><![CDATA[int ERL_TUPLE_SIZE(t)]]></c></tag>
120
<item>The number of elements in tuple <c><![CDATA[t]]></c>.</item>
121
<tag><c><![CDATA[ETERM *ERL_CONS_HEAD(t)]]></c></tag>
122
<item>The head element of list <c><![CDATA[t]]></c>.</item>
123
<tag><c><![CDATA[ETERM *ERL_CONS_TAIL(t)]]></c></tag>
124
<item>A List representing the tail elements of list <c><![CDATA[t]]></c>.</item>
129
<name><ret>ETERM *</ret><nametext>erl_cons(head, tail)</nametext></name>
130
<fsummary>Prepends a term to the head of a list.</fsummary>
136
<p>This function concatenates two Erlang terms, prepending
137
<c><![CDATA[head]]></c> onto <c><![CDATA[tail]]></c> and thereby creating a <c><![CDATA[cons]]></c> cell.
138
To make a proper list, <c><![CDATA[tail]]></c> should always be a
139
list or an empty list. Note that NULL is not a valid list.</p>
140
<p><c><![CDATA[head]]></c> is the new term to be added.</p>
141
<p><c><![CDATA[tail]]></c> is the existing list to which <c><![CDATA[head]]></c> will
143
<p>The function returns a new list.</p>
144
<p><c><![CDATA[ERL_CONS_HEAD(list)]]></c> and <c><![CDATA[ERL_CONS_TAIL(list)]]></c>
145
can be used to retrieve the head and tail components
146
from the list. <c><![CDATA[erl_hd(list)]]></c> and <c><![CDATA[erl_tl(list)]]></c> will do
147
the same thing, but check that the argument really is a list.</p>
149
<code type="none"><![CDATA[
150
ETERM *list,*anAtom,*anInt;
151
anAtom = erl_mk_atom("madonna");
152
anInt = erl_mk_int(21);
153
list = erl_mk_empty_list();
154
list = erl_cons(anAtom, list);
155
list = erl_cons(anInt, list);
156
... /* do some work */
157
erl_free_compound(list);
162
<name><ret>ETERM *</ret><nametext>erl_copy_term(term)</nametext></name>
163
<fsummary>Creates a copy of an Erlang term</fsummary>
168
<p>This function creates and returns a copy of the Erlang term
169
<c><![CDATA[term]]></c>.</p>
173
<name><ret>ETERM *</ret><nametext>erl_element(position, tuple)</nametext></name>
174
<fsummary>Extracts an element from an Erlang tuple</fsummary>
180
<p>This function extracts a specified element from an Erlang
182
<p><c><![CDATA[position]]></c> specifies which element to retrieve from
183
<c><![CDATA[tuple]]></c>. The elements are numbered starting from 1.</p>
184
<p><c><![CDATA[tuple]]></c> is an Erlang term containing at least
185
<c><![CDATA[position]]></c> elements.</p>
186
<p>The function returns a new Erlang term corresponding to the
187
requested element, or NULL if <c><![CDATA[position]]></c> was greater than
188
the arity of <c><![CDATA[tuple]]></c>.</p>
192
<name><ret>void</ret><nametext>erl_init(NULL, 0)</nametext></name>
193
<fsummary>Initialization routine</fsummary>
199
<marker id="erl_init"></marker>
200
<p>This function must be called before any of the others in
201
the <c><![CDATA[erl_interface]]></c> library in order to initialize the
202
library functions. The arguments must be specified as
203
<c><![CDATA[erl_init(NULL,0)]]></c>.</p>
207
<name><ret>ETERM *</ret><nametext>erl_hd(list)</nametext></name>
208
<fsummary>Extracts the first element from a list</fsummary>
213
<p>Extracts the first element from a list.</p>
214
<p><c><![CDATA[list]]></c> is an Erlang term containing a list.</p>
215
<p>The function returns an Erlang term corresponding to the
216
head element in the list, or a NULL pointer if <c><![CDATA[list]]></c> was
221
<name><ret>ETERM *</ret><nametext>erl_iolist_to_binary(term)</nametext></name>
222
<fsummary>Converts an IO list to a binary</fsummary>
227
<p>This function converts an IO list to a binary term.</p>
228
<p><c><![CDATA[list]]></c> is an Erlang term containing a list.</p>
229
<p>This function an Erlang binary term, or NULL if <c><![CDATA[list]]></c>
230
was not an IO list. </p>
231
<p>Informally, an IO list is a deep list of characters and
232
binaries which can be sent to an Erlang port. In BNF, an IO
233
list is formally defined as follows: </p>
234
<code type="none"><![CDATA[
240
| Byte (integer in the range [0..255])
247
<name><ret>char *</ret><nametext>erl_iolist_to_string(list)</nametext></name>
248
<fsummary>Converts an IO list to a zero terminated string</fsummary>
253
<p>This function converts an IO list to a '\\0' terminated C
255
<p><c><![CDATA[list]]></c> is an Erlang term containing an IO list. The IO
256
list must not contain the integer 0, since C strings may not
257
contain this value except as a terminating marker.</p>
258
<p>This function returns a pointer to a dynamically allocated
259
buffer containing a string. If <c><![CDATA[list]]></c> is not an IO list,
260
or if <c><![CDATA[list]]></c> contains the integer 0, NULL is returned. It
261
is the caller's responsibility free the allocated buffer
262
with <c><![CDATA[erl_free()]]></c>. </p>
263
<p>Refer to <c><![CDATA[erl_iolist_to_binary()]]></c> for the definition of an
268
<name><ret>int</ret><nametext>erl_iolist_length(list)</nametext></name>
269
<fsummary>Return the length of an IO list</fsummary>
274
<p>Returns the length of an IO list.
276
<p><c><![CDATA[list]]></c> is an Erlang term containing an IO list. </p>
277
<p>The function returns the length of <c><![CDATA[list]]></c>, or -1 if
278
<c><![CDATA[list]]></c> is not an IO list.</p>
279
<p>Refer to <c><![CDATA[erl_iolist_to_binary()]]></c> for the definition of
284
<name><ret>int</ret><nametext>erl_length(list)</nametext></name>
285
<fsummary>Determines the length of a list</fsummary>
290
<p>Determines the length of a proper list.</p>
291
<p><c><![CDATA[list]]></c> is an Erlang term containing proper list. In a
292
proper list, all tails except the last point to another list
293
cell, and the last tail points to an empty list.</p>
294
<p>Returns -1 if <c><![CDATA[list]]></c> is not a proper list.</p>
298
<name><ret>ETERM *</ret><nametext>erl_mk_atom(string)</nametext></name>
299
<fsummary>Creates an atom</fsummary>
304
<p>Creates an atom.</p>
305
<p><c><![CDATA[string]]></c> is the sequence of characters that will be
306
used to create the atom.</p>
307
<p>Returns an Erlang term containing an atom. Note that it is
308
the callers responsibility to make sure that <c><![CDATA[string]]></c>
309
contains a valid name for an atom.</p>
310
<p><c><![CDATA[ERL_ATOM_PTR(atom)]]></c> can be used to retrieve the
311
atom name (as a string). Note that the string is not
312
0-terminated in the atom. <c><![CDATA[ERL_ATOM_SIZE(atom)]]></c>returns
313
the length of the atom name.</p>
317
<name><ret>ETERM *</ret><nametext>erl_mk_binary(bptr, size)</nametext></name>
318
<fsummary>Creates a binary object</fsummary>
324
<p>This function produces an Erlang binary object from a
325
buffer containing a sequence of bytes.</p>
326
<p><c><![CDATA[bptr]]></c> is a pointer to a buffer containg data to be converted.</p>
327
<p><c><![CDATA[size]]></c> indicates the length of <c><![CDATA[bptr]]></c>.</p>
328
<p>The function returns an Erlang binary object.</p>
329
<p><c><![CDATA[ERL_BIN_PTR(bin)]]></c> retrieves a pointer to
330
the binary data. <c><![CDATA[ERL_BIN_SIZE(bin)]]></c> retrieves the
335
<name><ret>ETERM *</ret><nametext>erl_mk_empty_list()</nametext></name>
336
<fsummary>Creates an empty Erlang list</fsummary>
338
<p>This function creates and returns an empty Erlang list.
339
Note that NULL is not used to represent an empty list;
340
Use this function instead.</p>
344
<name><ret>ETERM *</ret><nametext>erl_mk_estring(string, len)</nametext></name>
345
<fsummary>Creates an Erlang string</fsummary>
351
<p>This function creates a list from a sequence of bytes.</p>
352
<p><c><![CDATA[string]]></c> is a buffer containing a sequence of
353
bytes. The buffer does not need to be zero-terminated.</p>
354
<p><c><![CDATA[len]]></c> is the length of <c><![CDATA[string]]></c>.</p>
355
<p>The function returns an Erlang list object corresponding to
356
the character sequence in <c><![CDATA[string]]></c>.</p>
360
<name><ret>ETERM *</ret><nametext>erl_mk_float(f)</nametext></name>
361
<fsummary>Creates an Erlang float</fsummary>
366
<p>Creates an Erlang float.</p>
367
<p><c><![CDATA[f]]></c> is a value to be converted to an Erlang float.</p>
369
<p>The function returns an Erlang float object with the value
370
specified in <c><![CDATA[f]]></c>.</p>
371
<p><c><![CDATA[ERL_FLOAT_VALUE(t)]]></c> can be used to retrieve the
372
value from an Erlang float.</p>
376
<name><ret>ETERM *</ret><nametext>erl_mk_int(n)</nametext></name>
377
<fsummary>Creates an Erlang integer</fsummary>
382
<p>Creates an Erlang integer.</p>
383
<p><c><![CDATA[n]]></c> is a value to be converted to an Erlang integer.</p>
385
<p>The function returns an Erlang integer object with the
386
value specified in <c><![CDATA[n]]></c>.</p>
387
<p><c><![CDATA[ERL_INT_VALUE(t)]]></c> can be used to retrieve the value
388
value from an Erlang integer.</p>
392
<name><ret>ETERM *</ret><nametext>erl_mk_list(array, arrsize)</nametext></name>
393
<fsummary>Creates a list from an array</fsummary>
395
<v>ETERM **array;</v>
399
<p>Creates an Erlang list from an array of Erlang terms, such
400
that each element in the list corresponds to one element in
402
<p><c><![CDATA[array]]></c> is an array of Erlang terms.</p>
403
<p><c><![CDATA[arrsize]]></c> is the number of elements in <c><![CDATA[array]]></c>.</p>
404
<p>The function creates an Erlang list object, whose length
405
<c><![CDATA[arrsize]]></c> and whose elements are taken from the terms in
406
<c><![CDATA[array]]></c>.</p>
410
<name><ret>ETERM *</ret><nametext>erl_mk_pid(node, number, serial, creation)</nametext></name>
411
<fsummary>Creates a process identifier</fsummary>
413
<v>const char *node;</v>
414
<v>unsigned int number;</v>
415
<v>unsigned int serial;</v>
416
<v>unsigned int creation;</v>
419
<p>This function creates an Erlang process identifier. The
420
resulting pid can be used by Erlang processes wishing to
421
communicate with the C node.</p>
422
<p><c><![CDATA[node]]></c> is the name of the C node.</p>
423
<p><c><![CDATA[number]]></c>, <c><![CDATA[serial]]></c> and <c><![CDATA[creation]]></c> are
424
arbitrary numbers. Note though, that these are limited in
425
precision, so only the low 15, 3 and 2 bits of these numbers
426
are actually used.</p>
427
<p>The function returns an Erlang pid object.</p>
428
<p><c><![CDATA[ERL_PID_NODE(pid)]]></c>, <c><![CDATA[ERL_PID_NUMBER(pid)]]></c>,
429
<c><![CDATA[ERL_PID_SERIAL(pid)]]></c> and <c><![CDATA[ERL_PID_CREATION(pid)]]></c>
430
can be used to retrieve\011the four values used to create the pid.</p>
434
<name><ret>ETERM *</ret><nametext>erl_mk_port(node, number, creation)</nametext></name>
435
<fsummary>Creates a port identifier</fsummary>
437
<v>const char *node;</v>
438
<v>unsigned int number;</v>
439
<v>unsigned int creation;</v>
442
<p>This function creates an Erlang port identifier. </p>
443
<p><c><![CDATA[node]]></c> is the name of the C node.</p>
444
<p><c><![CDATA[number]]></c> and <c><![CDATA[creation]]></c> are arbitrary numbers.
445
Note though, that these are limited in
446
precision, so only the low 18 and 2 bits of these numbers
447
are actually used.\011</p>
448
<p>The function returns an Erlang port object.</p>
449
<p><c><![CDATA[ERL_PORT_NODE(port)]]></c>, <c><![CDATA[ERL_PORT_NUMBER(port)]]></c>
450
and <c><![CDATA[ERL_PORT_CREATION]]></c> can be used to retrieve the three
451
values used to create the port. </p>
455
<name><ret>ETERM *</ret><nametext>erl_mk_ref(node, number, creation)</nametext></name>
456
<fsummary>Creates an old Erlang reference</fsummary>
458
<v>const char *node;</v>
459
<v>unsigned int number;</v>
460
<v>unsigned int creation;</v>
463
<p>This function creates an old Erlang reference, with
464
only 18 bits - use <c><![CDATA[erl_mk_long_ref]]></c> instead.</p>
465
<p><c><![CDATA[node]]></c> is the name of the C node.</p>
466
<p><c><![CDATA[number]]></c> should be chosen uniquely for each reference
467
created for a given C node.</p>
468
<p><c><![CDATA[creation]]></c> is an arbitrary number.</p>
469
<p>Note that <c><![CDATA[number]]></c> and <c><![CDATA[creation]]></c> are limited in
470
precision, so only the low 18 and 2 bits of these numbers
473
<p>The function returns an Erlang reference object.</p>
474
<p><c><![CDATA[ERL_REF_NODE(ref)]]></c>, <c><![CDATA[ERL_REF_NUMBER(ref)]]></c>, and
475
<c><![CDATA[ERL_REF_CREATION(ref)]]></c> to retrieve the three values used
476
to create the reference. </p>
480
<name><ret>ETERM *</ret><nametext>erl_mk_long_ref(node, n1, n2, n3, creation)</nametext></name>
481
<fsummary>Creates an Erlang reference</fsummary>
483
<v>const char *node;</v>
484
<v>unsigned int n1, n2, n3;</v>
485
<v>unsigned int creation;</v>
488
<p>This function creates an Erlang reference, with 82 bits.</p>
489
<p><c><![CDATA[node]]></c> is the name of the C node.</p>
490
<p><c><![CDATA[n1]]></c>, <c><![CDATA[n2]]></c> and <c><![CDATA[n3]]></c> can be seen as one big number
491
<c><![CDATA[n1*2^64+n2*2^32+n3]]></c> which should be chosen uniquely for
493
created for a given C node.</p>
494
<p><c><![CDATA[creation]]></c> is an arbitrary number.</p>
495
<p>Note that <c><![CDATA[n3]]></c> and <c><![CDATA[creation]]></c> are limited in
496
precision, so only the low 18 and 2 bits of these numbers
499
<p>The function returns an Erlang reference object.</p>
500
<p><c><![CDATA[ERL_REF_NODE(ref)]]></c>, <c><![CDATA[ERL_REF_NUMBERS(ref)]]></c>,
501
<c><![CDATA[ERL_REF_LEN(ref)]]></c> and
502
<c><![CDATA[ERL_REF_CREATION(ref)]]></c> to retrieve the values used
503
to create the reference. </p>
507
<name><ret>ETERM *</ret><nametext>erl_mk_string(string)</nametext></name>
508
<fsummary>Creates a string</fsummary>
513
<p>This function creates a list from a zero terminated string.</p>
514
<p><c><![CDATA[string]]></c> is the zero-terminated sequence of characters
515
(i.e. a C string) from which the list will be created.</p>
516
<p>The function returns an Erlang list.</p>
520
<name><ret>ETERM *</ret><nametext>erl_mk_tuple(array, arrsize)</nametext></name>
521
<fsummary>Creates an Erlang tuple from an array</fsummary>
523
<v>ETERM **array;</v>
527
<p>Creates an Erlang tuple from an array of Erlang terms.</p>
528
<p><c><![CDATA[array]]></c> is an array of Erlang terms.</p>
529
<p><c><![CDATA[arrsize]]></c> is the number of elements in <c><![CDATA[array]]></c>.</p>
530
<p>The function creates an Erlang tuple, whose arity is
531
<c><![CDATA[size]]></c> and whose elements are taken from the terms in
532
<c><![CDATA[array]]></c>.</p>
533
<p>To retrieve the size of a tuple, either use the
534
<c><![CDATA[erl_size]]></c> function (which checks the type of the checked
535
term and works for a binary as well as for a tuple), or the
536
<c><![CDATA[ERL_TUPLE_SIZE(tuple)]]></c> returns the arity of a tuple.
537
<c><![CDATA[erl_size()]]></c> will do the same thing, but it checks that
538
the argument really is a tuple.
539
<c><![CDATA[erl_element(index,tuple)]]></c> returns the element
540
corresponding to a given position in the tuple. </p>
544
<name><ret>ETERM *</ret><nametext>erl_mk_uint(n)</nametext></name>
545
<fsummary>Creates an unsigned integer</fsummary>
547
<v>unsigned int n;</v>
550
<p>Creates an Erlang unsigned integer.</p>
551
<p><c><![CDATA[n]]></c> is a value to be converted to an Erlang
552
unsigned integer.</p>
554
<p>The function returns an Erlang unsigned integer object with
555
the value specified in <c><![CDATA[n]]></c>.</p>
556
<p><c><![CDATA[ERL_INT_UVALUE(t)]]></c> can be used to retrieve the
557
value from an Erlang unsigned integer.</p>
561
<name><ret>ETERM *</ret><nametext>erl_mk_var(name)</nametext></name>
562
<fsummary>Creates an Erlang variable</fsummary>
567
<p>This function creates an unbound Erlang variable. The
568
variable can later be bound through pattern matching or assignment.</p>
569
<p><c><![CDATA[name]]></c> specifies a name for the variable.</p>
570
<p>The function returns an Erlang variable object with the
571
name <c><![CDATA[name]]></c>. </p>
575
<name><ret>int</ret><nametext>erl_print_term(stream, term)</nametext></name>
576
<fsummary>Prints an Erlang term</fsummary>
582
<p>This function prints the specified Erlang term to the given
584
<p><c><![CDATA[stream]]></c> indicates where the function should send its
586
<p><c><![CDATA[term]]></c> is the Erlang term to print.</p>
587
<p>The function returns the number of characters written, or a
588
negative value if there was an error.</p>
592
<name><ret>void</ret><nametext>erl_set_compat_rel(release_number)</nametext></name>
593
<fsummary>Set the erl_interface library in compatibility mode</fsummary>
595
<v>unsigned release_number;</v>
598
<marker id="erl_set_compat_rel"></marker>
599
<p>By default, the <c><![CDATA[erl_interface]]></c> library is only guaranteed
600
to be compatible with other Erlang/OTP components from the same
601
release as the <c><![CDATA[erl_interface]]></c> library itself. For example,
602
<c><![CDATA[erl_interface]]></c> from the OTP R10 release is not compatible
603
with an Erlang emulator from the OTP R9 release by default.</p>
604
<p>A call to <c><![CDATA[erl_set_compat_rel(release_number)]]></c> sets the
605
<c><![CDATA[erl_interface]]></c> library in compatibility mode of release
606
<c><![CDATA[release_number]]></c>. Valid range of <c><![CDATA[release_number]]></c>
607
is [7, current release]. This makes it possible to
608
communicate with Erlang/OTP components from earlier releases.</p>
610
<p>If this function is called, it may only be called once
611
directly after the call to the
612
<seealso marker="#erl_init">erl_init()</seealso> function.</p>
615
<p>You may run into trouble if this feature is used
616
carelessly. Always make sure that all communicating
617
components are either from the same Erlang/OTP release, or
618
from release X and release Y where all components
619
from release Y are in compatibility mode of release X.</p>
624
<name><ret>int</ret><nametext>erl_size(term)</nametext></name>
625
<fsummary>Return the arity of a tuple or binary</fsummary>
630
<p>Returns the arity of an Erlang tuple, or the
631
number of bytes in an Erlang binary object. </p>
632
<p><c><![CDATA[term]]></c> is an Erlang tuple or an Erlang binary object.</p>
633
<p>The function returns the size of <c><![CDATA[term]]></c> as described
634
above, or -1 if <c><![CDATA[term]]></c> is not one of the two supported
639
<name><ret>ETERM *</ret><nametext>erl_tl(list)</nametext></name>
640
<fsummary>Extracts the tail from a list</fsummary>
645
<p>Extracts the tail from a list.</p>
646
<p><c><![CDATA[list]]></c> is an Erlang term containing a list.</p>
647
<p>The function returns an Erlang list corresponding to the
648
original list minus the first element, or NULL pointer if
649
<c><![CDATA[list]]></c> was not a list.</p>
653
<name><ret>ETERM *</ret><nametext>erl_var_content(term, name)</nametext></name>
654
<fsummary>Extracts the content of a variable</fsummary>
660
<p>This function returns the contents of the specified
661
variable in an Erlang term.
663
<p><c><![CDATA[term]]></c> is an Erlang term. In order for this function
664
to succeed, <c><![CDATA[term]]></c> must be an Erlang variable with the
665
specified name, or it must be an Erlang list or tuple
666
containing a variable with the specified name. Other Erlang
667
types cannot contain variables.</p>
668
<p><c><![CDATA[name]]></c> is the name of an Erlang variable.</p>
669
<p>Returns the Erlang object corresponding to the value of
670
<c><![CDATA[name]]></c> in <c><![CDATA[term]]></c>. If no variable with the name
671
<c><![CDATA[name]]></c> was found in <c><![CDATA[term]]></c>, or if <c><![CDATA[term]]></c> is
672
not a valid Erlang term, NULL is returned.</p>