Modifiers
A modifier wraps a function with extra behavior that runs before and after it, without changing the function's own code. Use modifiers for logging, timing, validation, or any cross-cutting concern you want to keep out of your core logic.
What are modifiers
A modifier is defined with #m name() ... #ef and contains two blocks:before:, which runs right before the wrapped function, andafter:, which runs right after it finishes.
Syntax
And a regular function, defined the usual way:
Applying a modifier
Attach a modifier to a function call using square brackets:
Output:
The flow is straightforward — before runs, then the function body, then after:
Multiple modifiers
You can stack more than one modifier on the same call, separated by commas:
Output:
Execution order
With multiple modifiers, Astra wraps them in the order you list them — like layers around the function. before blocks run in the order listed (left to right), and after blocks run in the reverseorder (right to left). This is the same nesting pattern you'd see wrapping one function call inside another.
before last, but its after first — modifiers nest like brackets, not like a flat sequence.