Skip to content

std

The std module provides core language facilities.

Types

Name Description
Args Argument pack
Array Mutable ordered sequence
Bin Immutable binary data
BytecodeError Bytecode verification error
Bool Boolean (true / false)
CanceledError Strand cancellation
CompileError Compilation error
ConcurrencyError Concurrent access violation
CyclicImportError Cyclic module dependency
Dict Mutable ordered dictionary
Set Mutable ordered set
Error Abstract base error type
FieldError Nonexistent field access
Float 64-bit floating point
Func Callable value
Getter Abstract getter protocol type
ImmutableError Mutation of an immutable value
ImportError Module import failure
IndexError Out-of-bounds index access
Int 128-bit signed integer
AbortError Uncatchable host abort
Iter Abstract iterator type
Iterable Abstract iterable type
IterStop Error raised when an iterator is exhausted
MissingKeyError Required keyword argument not provided
MissingPosError Required positional argument not provided
Nil Type object for nil
OverflowError Integer overflow
Range Numeric range for iteration
Record Record with dot-syntax access
RuntimeError Ordinary runtime failure supertype
Setter Abstract setter protocol type
StateError Invalid operation for current state
Sinkable Abstract sinkable type
Sink Abstract sink type
SinkStop Error raised when a sink is closed
Str Immutable UTF-8 string
Sym Interned symbol
TimedOutError Strand timeout
Tuple Immutable ordered sequence
Type Type of types
TypeError Wrong type for an operation
UnexpectedKeyError Unexpected keyword argument
UnexpectedPosError Unexpected positional argument
UnsupportedError Unsupported operation
ValueError Invalid value for an operation
Value Abstract supertype of all values
ZeroDivError Integer division or modulo by zero

Values

NULLITER

Acts as both an iterator and a sink that performs no operations.

  • As an iterator: NULLITER never yields any items.
  • As a sink: NULLITER silently discards all items.

Functions

dbg value

Converts a value to its debug representation. Shows internal structure (e.g. quotes strings, shows type tags).

Parameters

Name Type Description
value the value to convert

Returns

Str

getter func

Builds a getter object from a callable.

Parameters

Name Type Description
func func callable used for field reads

Returns

Getter

class Config
  field port = 8080

  #[getter]
  pub def port obj
    obj.#port

setter func

Builds a setter object from a callable.

Parameters

Name Type Description
func func callable used for field writes

Returns

Setter

class Config
  #[setter]
  pub def port obj value
    obj.#_port = value

array ...values

Creates an array from positional arguments.

dict ...

Creates a dictionary from positional and keyword arguments.

tuple ...values

Creates a tuple from positional arguments.

record ...

Creates a record from keyword arguments.

Parameters

Name Type Description
keyword args become fields

Returns

Record

let r = record name: Alice age: 30
echo $r.name  # Alice

type value type?

Returns the value's type, or tests whether the value is an instance of type. See Type.

int value

Coerces or parses a value as an Int.

float value

Coerces or parses a value as a Float.

bool value

Converts a value to Bool according to its truthiness.

str value

Returns the general-purpose Str representation of a value.

sym value

Interns a string as a Sym.

arg value

Converts a value to its external argument representation. Preserves the literal textual form of values where possible, which is useful for passing values as command-line arguments to external programs.

Parameters

Name Type Description
value the value to convert

Returns

Str

hash ...values

Returns a hash code computed over all supplied values in sequence. Passing multiple values is useful for combining fields in a (hash) implementation:

def (hash) self
  hash $self.x $self.y $self.z

Parameters

Name Type Description
...values one or more values to hash

Returns

Int