Documentation
¶
Overview ¶
Package funcs implements source-local @func declarations. Function bodies are pure expressions, callable from projections, conditions, and argument maps.
Index ¶
Constants ¶
const ID = "func"
Variables ¶
var Directive = compiler.Directive{ Name: "func", Example: `@func commerce.totalMinor(subtotal_minor int, discount_minor int, tax_rate_percent int) int { let taxable_minor = subtotal_minor - discount_minor; let tax_minor = taxable_minor * tax_rate_percent / 100; taxable_minor + tax_minor } { total_minor: commerce.totalMinor(1250, 50, 10) }`, Handler: handleDirective, OpaqueBlock: true, }
Directive parses pure, typed function declarations. Its signature follows Go's name-then-type convention; braced bodies may use ordered expr-lang let bindings followed by a final expression that supplies the result.
Functions ¶
func Bundle ¶
Bundle contributes the @func directive, expression compiler, and projection primary for each prepared source. No function definitions are placed in a process-global registry.
func ExpressionCompilerFromMeta ¶
func ExpressionCompilerFromMeta(meta map[string]any) compiler.ExpressionCompiler
ExpressionCompilerFromMeta returns a compiler for all functions visible in one source, including functions mounted through its @include namespaces.
Types ¶
type FunctionDeclaration ¶
type FunctionDeclaration struct {
Name string
Parameters []projection.FunctionParameter
Result string
Body string
Position compiler.Position
}
FunctionDeclaration is the source-level representation stored by @func.