Advanced Features
Advanced Features
Generics
Functions can take type parameters with built-in constraints: Ordered, Eq, Numeric.
func abs<T: Numeric>(value: T) -> T: if (value < 0): return -value return value
func min<T: Ordered>(left: T, right: T) -> T: if (left < right): return left return rightMultiple constraints can be combined with +:
func example<T: Ordered + Eq>(left: T, right: T) -> bool: return left == rightGeneric structs and generic impl blocks are parsed by the compiler but are not yet fully available end to end. Use non-generic structs for production code.
pub
pub is a contextual keyword accepted on declarations. It is parsed and stored in the AST but does not yet affect visibility or module exports:
pub func api_function() -> i32: return 42intent
intent declares a constraint-based block that the compiler lowers to IR. An intent has optional minimize/maximize constraint expressions and an optional body block:
intent Optimize: minimize 1 body: let i: i32 = 0 while (i < 8): i = i + 1
func main() -> i32: return 0flow
flow declares a sequential pipeline with named stage blocks and an optional compensate block:
flow Transaction: stage acquire: let auth_state: i32 = 1 stage commit: let commit_state: i32 = 2 compensate: let rollback_state: i32 = 3
func main() -> i32: return 0What is NOT in the current compiler
The following features are not implemented in the current compiler and do not exist in the language today:
| Feature | Status |
|---|---|
enum | not implemented |
match | not implemented |
trait / impl for | not implemented |
type alias | not implemented |
unsafe blocks | not implemented |
defer | not implemented |
comptime | not implemented |
| closures / lambdas | not implemented |
range loops (0..10) | not implemented |
| array literals | not implemented |
| string interpolation | not implemented |
loop keyword | not implemented |
? result operator | not implemented |