pub struct Thunk(Rc<RefCell<ThunkRepr>>);
Expand description
A thunk is created for any value which requires non-strict
evaluation due to self-reference or lazy semantics (or both).
Every reference cycle involving Value
s will contain at least
one Thunk
.
Tuple Fields§
§0: Rc<RefCell<ThunkRepr>>
Implementations§
source§impl Thunk
impl Thunk
pub fn new_closure(lambda: Rc<Lambda>) -> Self
pub fn new_suspended(lambda: Rc<Lambda>, span: Span) -> Self
pub fn new_suspended_native( native: Box<dyn Fn() -> Result<Value, ErrorKind>>, ) -> Self
sourcepub fn new_suspended_call(callee: Value, arg: Value, span: Span) -> Self
pub fn new_suspended_call(callee: Value, arg: Value, span: Span) -> Self
Helper function to create a Thunk
that calls a function given as the
Value
callee
with the argument arg
when it is forced. This is
particularly useful in builtin implementations if the result of calling
a function does not need to be forced immediately, because e.g. it is
stored in an attribute set.
fn prepare_blackhole(&self, forced_at: Span) -> ThunkRepr
pub async fn force( myself: Thunk, co: GenCo, span: Span, ) -> Result<Value, ErrorKind>
pub async fn force_( myself: Thunk, co: &GenCo, span: Span, ) -> Result<Value, ErrorKind>
pub fn finalise(&self, stack: &[Value])
pub fn is_evaluated(&self) -> bool
pub fn is_suspended(&self) -> bool
sourcepub fn value(&self) -> Ref<'_, Value>
pub fn value(&self) -> Ref<'_, Value>
Returns a reference to the inner evaluated value of a thunk. It is an error to call this on a thunk that has not been forced, or is not otherwise known to be fully evaluated.
sourcefn unwrap_or_clone(self) -> Value
fn unwrap_or_clone(self) -> Value
Returns the inner evaluated value of a thunk, cloning it if the Rc has more than one strong reference. It is an error to call this on a thunk that has not been forced, or is not otherwise known to be fully evaluated.
pub fn upvalues(&self) -> Ref<'_, Upvalues>
pub fn upvalues_mut(&self) -> RefMut<'_, Upvalues>
sourcepub(crate) fn ptr_eq(&self, other: &Self) -> bool
pub(crate) fn ptr_eq(&self, other: &Self) -> bool
Do not use this without first reading and understanding
tvix/docs/value-pointer-equality.md
.
sourcepub(crate) fn debug_repr(&self) -> String
pub(crate) fn debug_repr(&self) -> String
Helper function to format thunks in observer output.