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.shippingFeeMinor(subtotalMinor int, destinationZone string) int = subtotalMinor >= 5000 && destinationZone == \"domestic\" ? 0 : 599",
Handler: handleDirective,
}
Directive parses one pure, single-expression function declaration per line. Its signature follows Go's name-then-type convention; only the body is expression syntax, not a Go statement block.
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.