pub struct LexicalEnv { /* private fields */ }Expand description
A lexical scope: a frame of name-to-value slots chained to its parent.
Cloning shares the same frame; child opens a nested
scope. Slots support deferred initialization so letrec can predefine names
before computing their values.
Implementations§
Source§impl LexicalEnv
impl LexicalEnv
Sourcepub fn define(&self, name: Symbol, value: Value) -> Result<()>
pub fn define(&self, name: Symbol, value: Value) -> Result<()>
Binds name to value in this frame.
Errors if name is already bound in the same frame (shadowing requires
a child scope).
Sourcepub fn lookup(&self, name: &Symbol) -> Result<Value>
pub fn lookup(&self, name: &Symbol) -> Result<Value>
Resolves name through this frame and its parents.
Errors if the name is undefined or was predefined but never initialized.
Sourcepub fn capture_cell(&self, name: &Symbol) -> Result<BindingCell>
pub fn capture_cell(&self, name: &Symbol) -> Result<BindingCell>
Captures name as a shared cell for closure formation.
Mutating the returned cell updates the lexical slot itself, so every closure that captures the same binding observes the same value.
Trait Implementations§
Source§impl Clone for LexicalEnv
impl Clone for LexicalEnv
Source§fn clone(&self) -> LexicalEnv
fn clone(&self) -> LexicalEnv
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LexicalEnv
impl Debug for LexicalEnv
Auto Trait Implementations§
impl Freeze for LexicalEnv
impl RefUnwindSafe for LexicalEnv
impl Send for LexicalEnv
impl Sync for LexicalEnv
impl Unpin for LexicalEnv
impl UnsafeUnpin for LexicalEnv
impl UnwindSafe for LexicalEnv
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more