cl-interpret: Add convenience function for binding variables

This commit is contained in:
John 2025-05-18 11:48:04 -04:00
parent 964917d2f0
commit f95c6ee239

View File

@ -99,6 +99,11 @@ impl Environment {
function.call(self, args) function.call(self, args)
} }
/// Binds a value to the given name in the current scope.
pub fn bind(&mut self, name: &str, value: impl Into<ConValue>) {
self.insert(name.into(), Some(value.into()));
}
/// Gets all registered globals, bound or unbound. /// Gets all registered globals, bound or unbound.
pub fn globals(&self) -> &HashMap<Sym, Option<ConValue>> { pub fn globals(&self) -> &HashMap<Sym, Option<ConValue>> {
&self.global &self.global