def
Define a user command or helper.
Syntax
Section titled “Syntax”def <name> <params> <body>Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
name |
command | helper |
|
params |
string |
Definition expression (see syntax variants below) |
body |
expression | block |
Examples
Section titled “Examples”# Constant helper - returns a fixed addressdef @myAddr "address" 0x44fA8E6f47987339850636F88629646662444217set $result @myAddr
# Helper with typed parametersdef @double "$n: number -> number" @num($n * 2)set $result @double(5)
# Boolean helperdef @isPositive "$n: number -> bool" @bool($n > 0)set $result @isPositive(5)
# Compositiondef @double "$n: number -> number" @num($n * 2)def @quadruple "$n: number -> number" @double(@double($n))set $result @quadruple(3)Syntax
Section titled “Syntax”# Define a constant helperdef @name "type" <value>
# Define a helper with parametersdef @name "$param1: type $param2: type -> returnType" <expression>
# Define a commanddef commandName "$param1: type $param2: type" ( ...)- The type signature string defines parameter names, types, and return type
- Parameters are prefixed with
$, optional params wrapped in[] - Helpers defined inside blocks (e.g.
if) are scoped to that block - Type inference: if the return type is omitted, it is inferred from the body
See Also
Section titled “See Also”- set — assign values to variables