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
| Name | Description |
|---|---|
| global_timer | A 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_epoch | The epoch time (in seconds) when the Aleph interpreter started. |
Types
| Name | Description |
|---|---|
| Action | Represents a Function that has no arguments and return no value. |
| ArithmeticError | Error thrown when arithmetic operations encounter invalid conditions or produce undefined results. |
| BenchmarkResult | Contains statistical results from benchmarking operations. |
| CSVDocument | Represents a CSV document that can be loaded from a file and queried. |
| CSVValueConverterFunc | A function type used to convert CSV string values to other types. |
| DynamicObject | A flexible object type that allows dynamic creation and modification of attributes at runtime. |
| Error | The base type for all exceptions and error conditions in Aleph. |
| EvalError | Error thrown when an error occurs during script evaluation or execution. |
| Func | Represents a Function that has no arguments and return a single value. |
| Function | Represents callable code blocks or routines. |
| Future | Represents the result of an asynchronous operation that may not be available yet. |
| InvalidArgumentError | This class defines the type of objects thrown as exceptions to report an invalid argument. |
| List | A dynamic array that can grow and shrink in size during runtime. |
| ListSorter | Represents a Function that can be used to sort a List. |
| LogicError | Error thrown when there is a flaw in the logic or internal structure of the program that could be detected before runtime. |
| Map | An associative container that stores key-value pairs in sorted order. |
| MapPair | Pair type that corresponds with the Map type. |
| Number | Represents numeric values in the language. This type is a supertype that encompasses both integer and real (floating-point) numbers. |
| Object | The root type of the language. All values are instances of Object. |
| OutOfRangeError | Error thrown when an operation attempts to access an element outside the valid range of a container or data structure. |
| Pair | A container that holds exactly two values, which may be of different types. |
| RuntimeError | Error thrown for errors that can only be detected during program execution. |
| Set | A container that stores unique elements in no particular order. |
| Slice | Represents a range specification for indexing operations with start, stop, and step parameters. |
| Slices | A collection of Slice objects used for multi-dimensional indexing and data access operations. |
| StringSorter | Represents a Function that can be used to sort a string. |
| Timer | A Timer is used to track elapsed time. |
| TimerDuration | Represents a duration of time with nanosecond precision. |
| TypeConverterFun | A function type used for converting values between different types. |
| TypeInfo | Contains metadata and information about types in the Aleph type system. |
| bool | Represents a logical value: either true or false. |
| complex | Represents a complex number with real and imaginary components. |
| integer | Represents whole numbers (positive, negative, or zero). Uses 64 bits precision, so it ranges between -2^31 and 2^31 - 1. |
| real | Represents floating-point numbers (numbers with fractional parts). Uses IEEE 754 double-precision semantics. |
| string | Represents a sequence of characters. |
| void | Represents 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
| Name | Description |
|---|---|
| abs | Get the absolute value of a number. |
| async | Executes a function asynchronously and returns a Future object. |
| available_threads | Returns the number of hardware threads available on this system. |
| await_all | Waits for every Future in the provided List and returns the completed results in order. |
| benchmark | Benchmarks a function by running it a specified number of times and collecting timing statistics. |
| benchmark_for | Benchmarks a function by running it repeatedly for a specified duration and collecting timing statistics. |
| binary_search | Returns 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. |
| bool | Converts a real to a bool (identity function). |
| complex | Converts a complex to a complex (identity function). |
| conjugate | Complex conjugates a number in-place. |
| conjugated | Get the complex conjugate of a number. |
| epoch | Returns the number of seconds since Unix epoch. |
| epoch_ms | Returns the number of milliseconds since Unix epoch. |
| epsilon | Returns the epsilon value of a integer |
| exit | Exits the Aleph interpreter with the specified return code. |
| from_json | Parses a JSON string and converts it to Aleph objects. |
| generate_range | Generates a range of integers from start to stop. |
| help | Returns help on a global variable or type. |
| imag | Get the imaginary part of a complex number. |
| integer | Converts a integer to a integer (identity function). |
| lowest | Returns the lowest value of a real |
| max | Returns the maximum value of a integer |
| max_threads | Returns the maximum number of threads Aleph is configured to use. |
| min | Returns the minimum value of a real |
| parallel_map | Applies a mapper function to every element of a List in parallel using the shared async thread pool. |
| phase | Get the complex phase of a number. |
| quit | Quits the Aleph interpreter with the specified return code. |
| real | Get the real part of a complex number. |
| set_max_threads | Sets the maximum number of threads Aleph will use. |
| sleep | Suspends execution for the specified number of seconds. |
| throw | Throws the specified value as an exception. |
| throws_exception | Executes an action and returns any exception message as a string. |
| time | Times the execution of a function and returns the elapsed duration. |
| to_json | Converts an Aleph object to a JSON string. |
| version | Returns the aleph version number. |
Module Symbols
| Name | Description |
|---|---|
! | 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. |