Skip to main content

Standard Library

The Aleph Standard Library provides essential types, functions, and utilities for Aleph programming.

It includes fundamental data types (numbers, strings, booleans), collection types (List, Map, Set, Pair), mathematical functions, string manipulation utilities, asynchronous programming, and comprehensive operator overloading.

The stdlib forms the foundation of the Aleph language runtime and is automatically available in all Aleph programs.

Global Constants

NameDescription
global_timerA global timer instance that can be used to measure elapsed time across the application. It is initialized when the module is loaded and can be used to track time without creating new Timer instances.
start_epochThe epoch time (in seconds) when the Aleph interpreter started.

Types

NameDescription
ActionRepresents a Function that has no arguments and return no value.
ArithmeticErrorError thrown when arithmetic operations encounter invalid conditions or produce undefined results.
BenchmarkResultContains statistical results from benchmarking operations.
CSVDocumentRepresents a CSV document that can be loaded from a file and queried.
CSVValueConverterFuncA function type used to convert CSV string values to other types.
DynamicObjectA flexible object type that allows dynamic creation and modification of attributes at runtime.
ErrorThe base type for all exceptions and error conditions in Aleph.
EvalErrorError thrown when an error occurs during script evaluation or execution.
FuncRepresents a Function that has no arguments and return a single value.
FunctionRepresents callable code blocks or routines.
FutureRepresents the result of an asynchronous operation that may not be available yet.
InvalidArgumentErrorThis class defines the type of objects thrown as exceptions to report an invalid argument.
ListA dynamic array that can grow and shrink in size during runtime.
ListSorterRepresents a Function that can be used to sort a List.
LogicErrorError thrown when there is a flaw in the logic or internal structure of the program that could be detected before runtime.
MapAn associative container that stores key-value pairs in sorted order.
MapPairPair type that corresponds with the Map type.
NumberRepresents numeric values in the language. This type is a supertype that encompasses both integer and real (floating-point) numbers.
ObjectThe root type of the language. All values are instances of Object.
OutOfRangeErrorError thrown when an operation attempts to access an element outside the valid range of a container or data structure.
PairA container that holds exactly two values, which may be of different types.
RuntimeErrorError thrown for errors that can only be detected during program execution.
SetA container that stores unique elements in no particular order.
SliceRepresents a range specification for indexing operations with start, stop, and step parameters.
SlicesA collection of Slice objects used for multi-dimensional indexing and data access operations.
StringSorterRepresents a Function that can be used to sort a string.
TimerA Timer is used to track elapsed time.
TimerDurationRepresents a duration of time with nanosecond precision.
TypeConverterFunA function type used for converting values between different types.
TypeInfoContains metadata and information about types in the Aleph type system.
boolRepresents a logical value: either true or false.
complexRepresents a complex number with real and imaginary components.
integerRepresents whole numbers (positive, negative, or zero). Uses 64 bits precision, so it ranges between -2^31 and 2^31 - 1.
realRepresents floating-point numbers (numbers with fractional parts). Uses IEEE 754 double-precision semantics.
stringRepresents a sequence of characters.
voidRepresents the absence of a value. It has exactly one value (void) and no methods, as it is not a value you operate on.

Module Functions

NameDescription
absGet the absolute value of a number.
asyncExecutes a function asynchronously and returns a Future object.
available_threadsReturns the number of hardware threads available on this system.
await_allWaits for every Future in the provided List and returns the completed results in order.
benchmarkBenchmarks a function by running it a specified number of times and collecting timing statistics.
benchmark_forBenchmarks a function by running it repeatedly for a specified duration and collecting timing statistics.
binary_searchReturns the index of the first element in the container that is not less than the given value. The container is assumed to be sorted and the bisection algorithm is used.
boolConverts a real to a bool (identity function).
complexConverts a complex to a complex (identity function).
conjugateComplex conjugates a number in-place.
conjugatedGet the complex conjugate of a number.
epochReturns the number of seconds since Unix epoch.
epoch_msReturns the number of milliseconds since Unix epoch.
epsilonReturns the epsilon value of a integer
exitExits the Aleph interpreter with the specified return code.
from_jsonParses a JSON string and converts it to Aleph objects.
generate_rangeGenerates a range of integers from start to stop.
helpReturns help on a global variable or type.
imagGet the imaginary part of a complex number.
integerConverts a integer to a integer (identity function).
lowestReturns the lowest value of a real
maxReturns the maximum value of a integer
max_threadsReturns the maximum number of threads Aleph is configured to use.
minReturns the minimum value of a real
parallel_mapApplies a mapper function to every element of a List in parallel using the shared async thread pool.
phaseGet the complex phase of a number.
quitQuits the Aleph interpreter with the specified return code.
realGet the real part of a complex number.
set_max_threadsSets the maximum number of threads Aleph will use.
sleepSuspends execution for the specified number of seconds.
throwThrows the specified value as an exception.
throws_exceptionExecutes an action and returns any exception message as a string.
timeTimes the execution of a function and returns the elapsed duration.
to_jsonConverts an Aleph object to a JSON string.
versionReturns the aleph version number.

Module Symbols

NameDescription
!Performs logical NOT operation.
!=Checks if two numbers are not equal.
%Calculates the remainder of the division of two numbers.
%=Calculates the remainder of division and assigns the result.
&Performs a bitwise AND operation.
&=Performs a bitwise AND operation and assigns the result.
*Multiplies two numbers.
**Exponentiates the left-hand side number by the right-hand side number.
**=Exponentiates the left-hand side number by the right-hand side number and assigns the result.
*=Multiplies two numbers and assigns the result.
+Returns the number unchanged.
++Increments the number by 1 and returns the result.
+=Adds two numbers and assigns the result.
-Negates the number unchanged.
--Decrements the number by 1 and returns the result.
-=Subtracts two numbers and assigns the result.
/Divides the left-hand side number by the right-hand side number.
/=Divides two numbers and assigns the result.
<Checks if the left-hand side number is less than the right-hand side number.
<<Performs a left bitwise shift.
<<=Performs a left bitwise shift and assigns the result.
<=Checks if the left-hand side number is less than or equal to the right-hand side number.
=Assigns the value of the right-hand side to the left-hand side.
==Checks if two numbers are equal.
>Checks if the left-hand side number is greater than the right-hand side number.
>=Checks if the left-hand side number is greater than or equal to the right-hand side number.
>>Performs a right bitwise shift.
>>=Performs a right bitwise shift and assigns the result.
^Performs a bitwise XOR operation.
^=Performs a bitwise XOR operation and assigns the result.
|Performs a bitwise OR operation.
|=Performs a bitwise OR operation and assigns the result.
~Performs a bitwise NOT operation.