Expand description
Runtime values of the Swan language.
The central type is Value, which represents every first-class Swan
value: scalars (Nothing, Bool, Numb, Text), collections (List,
Namespace, Tuple), callables (Func, Builtin), asynchronous results
(Promise), and the non-throwing error value Undefined.
§Tuples
Every Value is conceptually a tuple. Nothing is the empty tuple, any
non-Tuple value is a one-element tuple, and Value::Tuple is a tuple of
two or more items. Value::items, Value::pair, Value::map and
Value::normalize all work with this view. Tuples are always flat and
never contain Nothing once normalized.
§Submodules
Scope: lexical environment, also used as the storage ofNamespace.Undef: description of why an operation was undefined.BuiltinFn: wrapper around a native Rust function.Promise: single-assignment asynchronous value.
§Comparison and conversion
Value implements PartialEq and PartialOrd by hand (see the impl docs)
and converts to bool through From<Value> for bool.
Structs§
- Builtin
Fn - A native Rust function that can be called from Swan code.
- Pairs
- An iterator over the corresponding items of two values seen as tuples.
- Promise
- A single-assignment value that may not be available yet.
- Scope
- A lexical environment: a table of bindings with an optional parent.
- Value
Iter - An iterator over the items of a value seen as a tuple.
Enums§
- Undef
- Why a value is undefined: the payload of
Value::Undefined. - Value
- Any first-class Swan value.