WARNING
This article uses Unofficial terminology.
A term is a syntactic element of a formula. Each term has a data type that defines what operations can be performed on it.
Terms and Values
In evaluation, a term represents syntax, while a value represents result.
A formula such as:
=SUM(1, 2)contains the term SUM(1, 2), which evaluates to the value 3. Note that the term SUM(1, 2) is recursively defined, containing the primitive SUM and the number literals 1 and 2.
All values originate from terms, but not all terms reduce to values. For instance, terms that produce crash bugs do not reduce to values. Note however that errors are still values.
Lambda term
*Main article: Lambda term
Lambda terms are first-class. They can be passed as arguments to other functions, returned from other functions, and be assigned to variables. They are comprised of |literals and LAMBDA functions.
Primitive function
Primitive functions are not first-class and comprise every default function. The only operation that can be performed on primitive functions is application (e.g. applying them to lambda terms, such as SUM(1, 2, 3)).
Callable terms
A callable term is any term that can be applied to arguments.
Both primitive functions and lambda terms are callable, though they differ in behavior:
| Type | First-class | Definition Source | Example |
|---|---|---|---|
| Primitive function | No | Built into Sheets | SUM(1, 2, 3) |
| Lambda term | Yes | Defined within formulas | LAMBDA(x, x + 1)(2) |
Callables form the foundation of all computation in Sheets. During evaluation, a callable term receives arguments, applies them according to its definition, and returns a resulting value. Some callables, such as operators, have unique syntax but follow the same conceptual model.