@head @title Introduction
The Alore standard library provides many useful services that you can use in your programs. This reference manual contains descriptions of all standard Alore modules. If you are just starting to learn Alore, start with Introduction to Alore. It contains a short overview of the standard library. After that, come back to this document for the details. @h2 Notation
This section gives an overview of the notation used in the library reference.
Descriptions of functions, types and variables usually include type annotations. For example, consider the definition of function @ref{std::Chr}: @fun Chr(n as Int) as Str @desc Return a ... @end
The function header indicates that Chr accepts a single integer argument (due to as Int), and it returns a string (due to as Str).
Container types such as Array have a type argument (or arguments) within < and > that indicates the type of items; for example Array<Str> stands for an array of strings, and Map<Int, Str> stands for a map from integers to strings.
The type signatures of operations involving operators such as +, * or [] use a special notation for clarity. For example, consider the + operation for strings: @op x + y @optype{Str + Str -> Str} @desc Return the concatenation of two strings. @end
This means that you can add two string objects, and the result is a string. The first part (x + y) indicates the kind of the operation, and the second part indicates the types of the operands and the result (Str + Str ⇒ Str). The actual implementation method can be derived from the above description; in this case it is _add (the base type is Str): @fun _add(y as Str) as Str @end
Indexed array assignment is a more complex example:
@op array[n] = x @optype{Array Again the left part tells us that this is an indexed assignment operation.
The second part says that if the base object has type Array<T>
(for any T), and if the index has type Int, the rvalue must have
type T (or any type that is compatible with T). We know that
T can be replaced with any type from the definition of
Array: it is
given as Array<T>, which tells that T is a type variable.
If a function or an operation is given multiple descriptions or signatures,
it has an
intersection type (which is similar to
function overloading in other languages). For example,
@ref{std::Abs} has two signatures:
@fun Abs(x as Int) as Int
@fun Abs(x as Float) as Float
@desc Return the absolute value of an integer or a float.
@end
It is not important to understand the details of intersection types to
use these kinds of functions or operations.
Multiple function signatures