pub struct Env { /* private fields */ }Expand description
The names a running program can reach: the values it has assigned, the verbs it has named, and the arguments bound to its parameters.
An explicit definition runs with a frame of its own on top: J’s =.
writes there and =: writes to the globals, and a name is looked for in
the frame before the globals. Frames do not nest — a definition called
from another sees only its own locals, which is what both references do.
Implementations§
Source§impl Env
impl Env
pub fn new(args: Vec<Array>) -> Env
pub fn get(&self, name: &str) -> Option<Array>
pub fn assign(&mut self, name: String, value: Array, scope: Scope)
pub fn define(&mut self, name: String, verb: Verb)
pub fn undefine(&mut self, name: &str)
pub fn verb(&self, name: &str) -> Option<&Verb>
pub fn arg(&self, i: usize) -> Result<Array>
Sourcepub fn enter(
&mut self,
frame: HashMap<String, Array>,
def: Arc<ExplicitDef>,
span: Span,
) -> Result<()>
pub fn enter( &mut self, frame: HashMap<String, Array>, def: Arc<ExplicitDef>, span: Span, ) -> Result<()>
Start a definition’s frame. Fails rather than overflowing the stack.
Sourcepub fn leave(&mut self) -> HashMap<String, Array>
pub fn leave(&mut self) -> HashMap<String, Array>
End a definition’s frame and hand back the names it assigned.
Sourcepub fn current_def(&self) -> Option<Arc<ExplicitDef>>
pub fn current_def(&self) -> Option<Arc<ExplicitDef>>
The innermost definition now running; $: and ∇ name it.
Auto Trait Implementations§
impl !RefUnwindSafe for Env
impl !UnwindSafe for Env
impl Freeze for Env
impl Send for Env
impl Sync for Env
impl Unpin for Env
impl UnsafeUnpin for Env
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more