pub enum Value {
Show 14 variants
True,
False,
Int(IntType),
Float(FloatType),
String(String),
Symbol(Symbol),
List(List),
HashMap(HashMapRc),
NativeFunc(NativeFunc),
NativeClosure(Rc<RefCell<dyn FnMut(Rc<RefCell<Env>>, Vec<Value>) -> Result<Value, RuntimeError>>>),
Lambda(Lambda),
Macro(Lambda),
Foreign(Rc<dyn Any>),
TailCall {
func: Rc<Value>,
args: Vec<Value>,
},
}
Expand description
Value
encompasses all possible Lisp values, including atoms, lists, and
others.
Variants§
True
False
Int(IntType)
Float(FloatType)
String(String)
Symbol(Symbol)
List(List)
HashMap(HashMapRc)
NativeFunc(NativeFunc)
A native Rust function that can be called from lisp code
NativeClosure(Rc<RefCell<dyn FnMut(Rc<RefCell<Env>>, Vec<Value>) -> Result<Value, RuntimeError>>>)
A native Rust closure that can be called from lisp code (the closure can capture things from its Rust environment)
Lambda(Lambda)
A lisp function defined in lisp
Macro(Lambda)
A lisp macro defined in lisp
Foreign(Rc<dyn Any>)
A reference to a foreign value (struct, enum, etc)
TailCall
A tail-call that has yet to be executed. Internal use only!
Implementations§
source§impl Value
impl Value
pub const NIL: Value = _
sourcepub fn type_name(&self) -> &'static str
pub fn type_name(&self) -> &'static str
Examples found in repository?
src/interpreter.rs (line 321)
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
fn value_to_argnames(argnames: List) -> Result<Vec<Symbol>, RuntimeError> {
argnames
.into_iter()
.enumerate()
.map(|(index, arg)| match arg {
Value::Symbol(s) => Ok(s),
_ => Err(RuntimeError {
msg: format!(
"Expected list of arg names, but arg {} is a {}",
index,
arg.type_name()
),
}),
})
.collect()
}
Trait Implementations§
source§impl<'a> FromIterator<&'a Value> for List
impl<'a> FromIterator<&'a Value> for List
source§impl FromIterator<Value> for List
impl FromIterator<Value> for List
source§impl Ord for Value
impl Ord for Value
source§impl PartialEq<Value> for Value
impl PartialEq<Value> for Value
source§impl PartialOrd<Value> for Value
impl PartialOrd<Value> for Value
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more