# Erlang Programming/Terms

← Getting Started | Pattern Matching →
The basic unit of expressing a value in Erlang is the term. Terms are comprised of one of Erlang's simple or complex types.

## Integers

Integer constants are written as numbers, optionally prefixed with a base and the octothorpe (#):
Erlang uses arbitrary-precision integers, which support integers with any number of digits.
Erlang also provides another syntactic shortcut: you can write an integer as the dollar sign ($) and a character, and the value is the ASCII value of that character. This is of use when handling strings, as strings are typically represented in Erlang as lists of integers (see Strings, below).

## Floats

Floats (floating-point numbers) are written as numbers with decimal places, optionally with an exponent separated from the number with the letter e.

## Atoms

Atoms are named constants. Atoms begin with a lower-case letter and can contain letters, digits and the underscore character (_); or they are quoted with single quotes (').
The special atoms true and false represent boolean values.
Atoms are often used as the keys in key-value pairs, indicators of success and failure (e.g. ok and error) and to identify parts of a complicated structure for Pattern Matching.

## Tuples

Tuples are terms composed of multiple values, and are of fixed length. Tuples are surrounded by braces ({ and }), and the elements of the tuple (any Erlang term, including tuples) are separated by commas.
The 3rd example shows something called a tagged tuple. Where possible use tagged tuples as they make it clear what the tuple is supposed to represent. Later on we will look at records which is just a shorthand for tagged tuples.

## Lists

Lists are terms composed of multiple values, of varying length. Lists are surrounded by brackets ([ and ]) and each member of the list (any Erlang term, including lists) separated with commas.
Lists can also be composed of a head and tail portion, separated by the vertical bar character (|): [Head|Tail]. The Tail can be any valid Erlang term, but is usually a list representing the members of the list after the head.
Lists in which the smallest possible tail is the empty list () are known as well-formed lists.

### Strings

Erlang has no separate string type. Strings are usually represented by lists of integers (and the string module of the standard library manipulates such lists). Each integer represents the ASCII (or other character set encoding) value of the character in the string. For convenience, a string of characters enclosed in double quotes (") is equivalent to a list of the numerical values of those characters.
The Erlang shell "guesses" whether a given list is a printable string and prints it that way for convenience.

## Pids

A Pid or process id is a special type in Erlang. To see what one looks like you can get the pid of yourself with self.

## Refs

A ref (or reference) is a term which is unique, even across Erlang nodes. You can create a new ref by calling erlang:make_ref. A reference is only used as a unique tag or identifier. An Erlang reference should not be confused with a reference in C/C++.

## Other types

Erlang has other types, such as funs (closures), bit-strings, binaries (continuous blocks of arbitrary data) and ports (port identifiers), that will be covered in their appropriate sections.