Home

Awesome

cl-erlang-term

Version: 0.2.3

cl-erlang-term is a Common Lisp library for encoding and decoding objects in the Erlang External Term Format.

How to install

Use Quicklisp to install cl-erlang-term.

> (ql:quickload :erlang-term)

Dependencies

Optional dependencies:

How to run the unit-tests

> (ql:quickload :erlang-term-test)
...
> (erlang-term-test:run-all-tests)

API

Encoding/decoding

[Function]
decode bytes &key start version-tag => erlang-term, position

Decodes the sequence bytes into an Erlang term, starting from position start. If version-tag has an integer value, bytes is expected to begin with a version tag byte of that value.

start defaults to 0. version-tag defaults to 131.

position is the location in bytes where the decoding ended.

[Function]
encode term &key version-tag compressed => bytes

Encodes term into a sequence of bytes. If version-tag has an integer value, bytes will start with a version tag byte of that value. If compressed is true, the encoded term will be zlib-compressed.

version-tag defaults to 131. compressed defaults to false.

Erlang object functions

Creating Erlang objects

[Function]
binary &rest bytes => binary

Creates a new Erlang binary with the contents of bytes.

[Function]
binary-to-string binary => string

Converts binary to a string.

[Function]
bytes-to-binary bytes => binary

Creates a new Erlang binary with the contents from the byte sequence bytes.

[Function]
make-atom string => atom

Creates a new Erlang atom (a symbol) with the name of string. The symbol is interned in the package designated by *atom-symbol-package*.

[Function]
make-pid node id serial creation => pid

Creates a new Erlang pid identified by the values of node, id, serial, and creation.

[Function]
make-port node id creation => port

Creates a new Erlang port identified by the values of node, id, and creation.

[Function]
make-reference node id creation => reference

Creates a new Erlang reference identified by the values of node, id, and creation.

[Function]
string-to-binary string => binary

Creates a new Erlang binary with the contents of string converted to bytes.

[Function]
tuple &rest erlang-translatable-objects => tuple

Creates a new Erlang tuple with erlang-translatable-objects as elements.

Erlang object accessors

[Reader]
bytes binary => byte-vector

Reader method for getting the contents of binary as byte vector.

[Reader]
bits-in-last-byte bit-binary => number-of-bits

Reader method for getting the number of bits in the last byte of bit-binary.

[Reader]
arity fun-or-tuple => arity

Reader method for getting the arity of either an Erlang fun or an Erlang tuple. The arity of a fun is the number of arguments it takes. The arity of a tuple is the number of elements in it.

[Reader]
size binary-or-tuple => size

Reader method for getting the size of either an Erlang binary or an Erlang tuple. The size of a binary is the number of bytes in it. The size of a tuple is the number of elements in it.

[Reader]
elements tuple => vector

Reader method for getting the elements of tuple as a vector.

[Function]
tuple-arity tuple => arity

Function for getting the number of elements in a tuple.

[Function]
tuple-ref tuple pos => element

Function for getting the element in tuple at position pos.

[Reader]
node identifier => node-name

Reader method for getting the node name from identifier, which is an Erlang pid, port, or reference.

[Reader]
module fun => module-name

Reader method for getting the module name from an Erlang fun.

Generic Erlang object functions

[Generic function]
match-p object-a object-b => boolean

Returns true if object-a and object-b match in the Erlang sense, i.e. they are structurally equivalent. Otherwise returns false.

Variables

[Constant variable]
+protocol-version+

The protocol version byte tag used in the Erlang External Term Format.

Value: 131

[Special variable]
*atom-symbol-package*

The package in which atom symbols are interned. Symbols are uninterned if NIL.

Default value: :keyword

[Special variable]
*erlang-false-is-lisp-nil*

Treat the Erlang atom false as the Lisp symbol NIL instead of '|false|.

Default value: false

[Special variable]
*erlang-string-is-lisp-string*

Treat Erlang strings as Lisp strings instead of lists of integers.

Default value: false

[Special variable]
*erlang-true-is-lisp-t*

Treat the Erlang atom true as the Lisp symbol T instead of '|true|.

Default value: false

[Special variable]
*lisp-nil-at-tail-is-erlang-empty-list*

Treat the Lisp symbol NIL at the tail of a list as the empty list instead of as the Erlang atom 'NIL'.

Default value: true

[Special variable]
*lisp-nil-is-erlang-empty-list*

Treat the Lisp symbol NIL as the empty list instead of as the Erlang atom 'NIL'.

Default value: true

[Special variable]
*lisp-nil-is-erlang-false*

Treat the Lisp symbol NIL as the Erlang atom false instead of 'NIL'.

Default value: false

[Special variable]
*lisp-string-is-erlang-binary*

Treat Lisp strings as Erlang binaries instead of as lists of integers.

Default value: false

[Special variable]
*lisp-t-is-erlang-true*

Treat the Lisp symbol T as the Erlang atom true instead of 'T'.

Default value: false

Types

Abstract types

[Type]
erlang-translatable

The base type for all types of objects that may be translated to Erlang terms.

Directly translatable types: integer, float, symbol, string, and list if all elements also are translatable.

Other types of Erlang terms are translated to subtypes of erlang-object.

[Class]
erlang-object

The base class for all Erlang term types that are not directly translatable to Lisp types.

[Class]
erlang-fun (erlang-object)

The base class for the different representations of Erlang funs.

[Class]
erlang-internal-fun (erlang-fun, erlang-object)

The base class for the two different representations of internal Erlang funs.

Concrete types

[Class]
erlang-binary (erlang-object)

Represents an Erlang binary or bit-binary.

[Class]
erlang-external-fun (erlang-fun, erlang-object)

Represents an external Erlang fun: fun M:F/A.

[Class]
erlang-new-internal-fun (erlang-internal-fun, erlang-fun, erlang-object)

Represents an internal Erlang fun: fun F/A and fun(Arg1,..) -> ... end.

[Class]
erlang-old-internal-fun (erlang-internal-fun, erlang-fun, erlang-object)

Represents an internal Erlang fun: fun F/A and fun(Arg1,..) -> ... end.

[Class]
erlang-pid (erlang-object)

Represents an Erlang pid.

[Class]
erlang-port (erlang-object)

Represents an Erlang port.

[Class]
erlang-reference (erlang-object)

Represents an Erlang reference.

[Class]
erlang-tuple (erlang-object)

Represents an Erlang tuple.