function

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package function provides the Function type and related methods.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArgInfo

type ArgInfo struct {
	Name        string
	Type        datatype.DataType
	Description string
}

ArgInfo defines the information for a function argument or return value.

type DeprecationInfo

type DeprecationInfo struct {
	IsDeprecated bool
	Description  string
	Version      string
}

DeprecationInfo defines the information for a deprecation.

type Documentation

type Documentation struct {
	Name            string
	Description     string
	Since           string
	DeprecationInfo DeprecationInfo
	Examples        []string
}

Documentation defines the documentation for a function.

type EvaluatorInterface

type EvaluatorInterface interface {
	AddToBuffer(format string, args ...any)
	Terminate(code byte)
}

EvaluatorInterface defines the interface that functions need from the evaluator.

type Handler

type Handler func(
	e EvaluatorInterface,
	args []datavalue.Value,
) (datavalue.Value, error)

Handler defines the handler for a function.

type Info

type Info struct {
	Documentation Documentation
	PackageName   string
	Handler       Handler
	FunctionType  Type
	Parameters    []ArgInfo
	ReturnValues  []ArgInfo
	IsBuiltin     bool
}

Info defines the information for a function.

func MakeFunction

func MakeFunction(
	documentation Documentation,
	packageName string,
	functionType Type,
	parameters []ArgInfo,
	returnValues []ArgInfo,
	isBuiltin bool,
	impl func(e EvaluatorInterface, args []datavalue.Value) datavalue.Value,
) Info

MakeFunction creates a new function definition.

func (*Info) Expr

func (f *Info) Expr() string

Expr returns the function signature as a string.

type PackageInfo

type PackageInfo struct {
	Functions map[string]Info
}

PackageInfo defines the information for a package.

type Type

type Type int

Type defines the type of function.

const (
	// FunctionTypeFixed defines function with a fixed number of arguments.
	FunctionTypeFixed Type = iota
	// FunctionTypeVariadic defines function with a variadic number of arguments.
	FunctionTypeVariadic
	// FunctionTypeMixedVariadic defines function with a mixed number of arguments.
	FunctionTypeMixedVariadic
)

Jump to

Keyboard shortcuts

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