funcs

package
v0.94.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package funcs implements source-local @func declarations. Function bodies are pure expressions, callable from projections, conditions, and argument maps.

Index

Constants

View Source
const ID = "func"

Variables

View Source
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

func Bundle(_ map[string]string) compiler.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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL