From 477ab55fe1ac19bb82162bdbedba0b5e46f4e9ad Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Fri, 3 May 2019 19:07:07 +0200 Subject: erl_interface: Document ei_set_compat_rel The changes in 6465de7e3a5393a80ed0e2c63f012fd126de706f. --- lib/erl_interface/doc/src/ei.xml | 56 ++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/lib/erl_interface/doc/src/ei.xml b/lib/erl_interface/doc/src/ei.xml index 7808bfd94f..c22f3fb0ce 100644 --- a/lib/erl_interface/doc/src/ei.xml +++ b/lib/erl_interface/doc/src/ei.xml @@ -849,30 +849,48 @@ ei_encode_tuple_header(buf, &i, 0); -

By default, the ei library is only guaranteed - to be compatible with other Erlang/OTP components from the same - release as the ei library itself. For example, - ei from - Erlang/OTP R10 is not compatible with an Erlang emulator - from Erlang/OTP R9 by default.

-

A call to ei_set_compat_rel(release_number) sets - the ei library in compatibility mode of release - release_number. Valid range of - release_number - is [7, current release]. This makes it possible to - communicate with Erlang/OTP components from earlier releases.

+

In general, the ei library is guaranteed + to be compatible with other Erlang/OTP components that are 2 major + releases older or newer than the ei library itself.

+

Sometimes an exception to the above rule has to be made to make new + features (or even bug fixes) possible. A call to + ei_set_compat_rel(release_number) sets + the ei library in compatibility mode of OTP release + release_number.

+

The only useful value for release_number is currently + 21. This will only be useful and have an effect if bit + strings or export funs are received from a connected + node. Before OTP 22, bit strings and export funs were not supported by + ei. They were instead encoded using an undocumented fallback + tuple format when sent from the emulator to ei:

+ + Bit string +

The term <<42, 1:1>> was encoded as + {<<42, 128>>, 1}. The first element of the tuple is a + binary and the second element denotes how many bits of the last bytes + are part of the bit string. In this example only the most significant + bit of the last byte (128) is part of the bit string.

+
+ Export fun +

The term fun lists:map/2 was encoded as + {lists,map}. A tuple with the module, function and a missing + arity.

+
+
+

If ei_set_compat_rel(21) is not called then a connected + emulator will send bit strings and export funs correctly encoded. The + functions ei_decode_bitstring + and ei_decode_fun + has to be used to decode such terms. Calling + ei_set_compat_rel(21) should only be done as a workaround to + keep an old implementation alive, which expects to receive the + undocumented tuple formats for bit strings and/or export funs. +

If this function is called, it can only be called once and must be called before any other functions in the ei library are called.

- -

You can run into trouble if this feature is used - carelessly. Always ensure that all communicating - components are either from the same Erlang/OTP release, or - from release X and release Y where all components - from release Y are in compatibility mode of release X.

-
-- cgit v1.2.3