datavalue

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: 6 Imported by: 0

Documentation

Overview

Package datavalue provides the Value type and related methods.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Value

type Value struct {
	DataType datatype.DataType

	Num    float64
	Str    string
	Bool   bool
	Func   *ast.FuncDeclarationStatement
	Values []Value
	Error  error
	Any    any
}

Value represents a value in the language.

func Any added in v0.1.1

func Any(a any) Value

Any creates a new any value.

func Array added in v0.1.1

func Array(values ...Value) Value

Array creates a new array value.

func Bool

func Bool(b bool) Value

Bool creates a new boolean value.

func Error added in v0.1.1

func Error(e error) Value

Error creates a new error value.

func Function added in v0.1.1

func Function(fn *ast.FuncDeclarationStatement) Value

Function creates a new function value.

func Null

func Null() Value

Null creates a new null value.

func Number

func Number(n float64) Value

Number creates a new number value.

func String

func String(s string) Value

String creates a new string value.

func Tuple added in v0.1.1

func Tuple(values ...Value) Value

Tuple creates a new tuple value.

func (Value) AsArray added in v0.1.1

func (v Value) AsArray() ([]Value, error)

AsArray returns the value as an array.

func (Value) AsBool

func (v Value) AsBool() (bool, error)

AsBool returns the value as a boolean.

func (Value) AsError added in v0.1.1

func (v Value) AsError() (error, error)

AsError returns the value as an error.

func (Value) AsFunction added in v0.1.1

func (v Value) AsFunction() (*ast.FuncDeclarationStatement, error)

AsFunction returns the value as a function.

func (Value) AsNumber

func (v Value) AsNumber() (float64, error)

AsNumber returns the value as a number.

func (Value) AsString

func (v Value) AsString() (string, error)

AsString returns the value as a string.

func (Value) AsTuple added in v0.1.1

func (v Value) AsTuple() ([]Value, error)

AsTuple returns the value as a tuple.

func (Value) Equals added in v0.1.1

func (v Value) Equals(other Value) bool

Equals returns if two values are equal.

func (Value) IsTruthy added in v0.1.2

func (v Value) IsTruthy() bool

IsTruthy checks if the provided value is truthy.

func (Value) ToString

func (v Value) ToString() string

ToString returns the string representation of the value.

Jump to

Keyboard shortcuts

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