Skip to main content

Value

Enum Value 

Source
pub enum Value {
Show 13 variants Nil, Boolean(bool), Number(isize), Symbol(ArenaIndex), Cons { car: ArenaIndex, cdr: ArenaIndex, }, String { len: usize, data: ArenaIndex, }, Char(char), Operative { params_envparam: ArenaIndex, body_env: ArenaIndex, }, Applicative(ArenaIndex), Builtin(BuiltinId), Environment { bindings: ArenaIndex, parents: ArenaIndex, }, Inert, Ignore,
}
Expand description

A Lisp value stored in the arena. Variants can only inline max two arenaindex sized data.

Variants§

§

Nil

The empty list / nil.

§

Boolean(bool)

§

Number(isize)

Integer number.

§

Symbol(ArenaIndex)

A symbol, pointing to a String value that holds the name.

§

Cons

A cons cell (pair) with inline car and cdr.

Fields

§

String

A string with inline length and pointer to character data.

Fields

§len: usize
§

Char(char)

A character.

§

Operative

Compound operative (vau closure / fexpr). Created by (vau params env-param body). params_envparam = (params . env-param), body_env = (body . closed-env)

Fields

§params_envparam: ArenaIndex
§body_env: ArenaIndex
§

Applicative(ArenaIndex)

Applicative wrapper: evaluates arguments, then calls inner combiner. Created by (wrap combiner). The inner combiner is any callable: Operative, Builtin, or even another Applicative.

§

Builtin(BuiltinId)

Rust-native primitive operative. Always an operative — receives unevaluated args + caller env. Applicative primitives (like +) are (wrap (Builtin id)) at init time.

§

Environment

A first-class environment with lexical parent chain. bindings: alist of (symbol . value) pairs in this frame. parents: cons-list of parent environments, or NIL for top-level.

Fields

§bindings: ArenaIndex
§parents: ArenaIndex
§

Inert

The inert value, written #inert. Returned by combiners whose primary purpose is side-effect (e.g. $define!).

§

Ignore

The ignore value, written #ignore. Used specifically for parameter matching in formal parameter trees.

Implementations§

Source§

impl Value

Source

pub fn type_name(&self) -> &'static str

Returns the type name as a static string (for error messages).

Source

pub fn is_self_evaluating(self) -> bool

True for self-evaluating forms (literals, closures, builtins).

Self-evaluating values exclude symbols and cons cells (which require lookup / dispatch).

Source

pub fn is_immutable(self) -> bool

True for immutable, encapsulated types whose identity is determined by value rather than arena slot (used by eq?).

Source

pub fn as_number(self) -> Result<isize, ArenaError>

Extract the numeric value, or Err(TypeError) if not a number.

Source

pub fn as_cons(self) -> Result<(ArenaIndex, ArenaIndex), ArenaError>

Extract the car and cdr of a cons cell.

Source

pub fn as_symbol(self) -> Result<ArenaIndex, ArenaError>

Extract the symbol’s string index.

Source

pub fn as_bool(self) -> Result<bool, ArenaError>

Extract the boolean value, or Err(TypeError) if not a boolean.

Source

pub fn as_applicative(self) -> Result<ArenaIndex, ArenaError>

Extract the inner combiner of an applicative, or Err(TypeError).

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Value

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Value

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<BuiltinId> for Value

Source§

fn from(v: BuiltinId) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Value

Source§

fn from(v: bool) -> Self

Converts to this type from the input type.
Source§

impl From<char> for Value

Source§

fn from(v: char) -> Self

Converts to this type from the input type.
Source§

impl From<isize> for Value

Source§

fn from(v: isize) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Value

Source§

fn eq(&self, other: &Value) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const N: usize> Trace<Value, N> for Value

Source§

fn trace<F: FnMut(ArenaIndex)>(&self, tracer: F)

Trace all ArenaIndex references contained in this value. Read more
Source§

fn trace_with_arena<F: FnMut(ArenaIndex)>( &self, arena: &Arena<Value, N>, tracer: F, )

Trace with arena access for types that store metadata in the arena. Read more
Source§

impl Copy for Value

Source§

impl StructuralPartialEq for Value

Auto Trait Implementations§

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnsafeUnpin for Value

§

impl UnwindSafe for Value

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.