Module definitions
Module definitions in Rell create reusable code components, including entities, objects, structs, enums, queries, operations, and functions. Abstract modules serve as templates, namespaces organize code, and external modules enable cross-blockchain access. Mount names provide flexible identification and mapping of components.
Identifiers are unique names for variables, functions, and keywords, following specific syntax rules with letters,
digits, and underscores (e.g., function
, entity
, struct
).
Entities store data long-term, with unique IDs and support relationships through keys and indices. The
@log
annotation makes them immutable.
Objects are singleton structures initialized at startup, with default attributes that cannot be created or deleted by code.
Structs are in-memory structures with default or mutable attributes, managed by the garbage collector, and can encapsulate function parameters.
Enums are sets of constants with unique integer values and built-in functions like T.values()
to list
values.
Queries return GTV-compatible data and do not modify the database, with simple or explicit return statement options.
Operations modify data, have no return value, and are declared with the operation
keyword. The
require
statement enforces execution conditions.
Functions offer reusable logic, support various return types, and include features like default parameters, named arguments, and partial application.
Abstract modules and functions provide templates for customization. Client modules import and override these components to create functional versions.
Namespaces group related modules, entities, and functions for better code organization.
The @external
annotation allows access to external blockchain entities within the same container.
These modules must use @log
and are filtered by block height.
Mount names identify components and map entities/objects to SQL tables. The @mount
annotation
customizes names with support for relative naming using .
(append) and ^
(remove).