Cover by Francesco Cesarini, Simon Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

Built-in Functions

The following subsections will familiarize you with a few of the more commonly used built-in functions grouped according to the type of function, with examples illustrating their use. We will refer to built-in functions as BIFs, a practice almost universal in the Erlang community. Standard and nonstandard BIFs are listed in the manual page of the erlang module.

BIFs are usually written in C and integrated into the virtual machine (VM), and can be used to manipulate, inspect, and retrieve data as well as interact with the operating system. An example of a data manipulation function is the conversion of an atom to a string: atom_to_list/1. Other BIFs, such as length/1, which returns the length of a list, are implemented in the runtime system for efficiency.

Originally, all built-in functions were considered to belong to the module erlang, but they have made their way to other modules for practicality and efficiency reasons. Among the modules that contain built-in functions are ets and lists.

Although most built-in functions are seen as being an integral part of Erlang, others are VM-dependent and do not necessarily exist in other VM implementations or even in specific OS ports of the existing VM. Standard built-in functions are auto-imported, so you can call them without the module prefix. Nonstandard BIFs, however, have to be prefixed with the erlang module prefix, as in erlang:function. Examples of nonstandard built-in functions include erlang:hash(Term, Range)

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required