Skip to main content

Term

Enum Term 

Source
pub enum Term {
    Literal(Datum),
    Ref(Ref),
    Local(Symbol),
    Let {
        name: Symbol,
        value: Box<Term>,
        body: Box<Term>,
    },
    Op {
        op: OpKey,
        input: Box<Term>,
    },
    Call {
        target: Box<Term>,
        args: Vec<Term>,
    },
    Seq(Vec<Term>),
    Quote {
        mode: QuoteMode,
        datum: Datum,
    },
    Annotated {
        term: Box<Term>,
        annotations: Vec<(Symbol, Datum)>,
    },
    Extension {
        tag: Symbol,
        payload: Datum,
    },
}
Expand description

Lowered executable form.

Current Expr values lower as follows:

  • scalar data -> Term::Literal
  • Expr::Symbol -> Term::Ref(Ref::Symbol)
  • Expr::Local -> Term::Local
  • data-only list, vector, map, and set -> Term::Literal
  • call -> Term::Call
  • infix, prefix, and postfix -> Term::Call with a symbolic target
  • block -> Term::Seq
  • quote -> Term::Quote over pure Datum
  • annotated -> Term::Annotated with datum annotations
  • extension -> Term::Extension with a datum payload

Variants§

§

Literal(Datum)

A constant datum value.

§

Ref(Ref)

A reference resolved through the registry or substrate.

§

Local(Symbol)

A lexical local binding referenced by name.

§

Let

A local binding form: bind name to value within body.

Fields

§name: Symbol

The bound name.

§value: Box<Term>

The term producing the bound value.

§body: Box<Term>

The body evaluated with the binding in scope.

§

Op

An explicit operation invocation over one input term.

Fields

§op: OpKey

The operation key naming the op.

§input: Box<Term>

The input term the op consumes.

§

Call

A call of target with positional args.

Fields

§target: Box<Term>

The term producing the callable target.

§args: Vec<Term>

The positional argument terms.

§

Seq(Vec<Term>)

A sequence of terms evaluated in order.

§

Quote

A quoted datum carried at a given quote mode.

Fields

§mode: QuoteMode

The quote mode (quote, quasiquote, …).

§datum: Datum

The quoted datum.

§

Annotated

A term carrying datum-valued annotations.

Fields

§term: Box<Term>

The annotated inner term.

§annotations: Vec<(Symbol, Datum)>

The name/datum annotation pairs.

§

Extension

An open extension term with a tag and datum payload.

Fields

§tag: Symbol

The extension tag.

§payload: Datum

The extension payload datum.

Implementations§

Source§

impl Term

Source

pub fn lower(expr: Expr) -> Result<Self>

Lowers a checked Expr into its executable Term form.

This walks the expression graph and produces the lowered representation described on Term; it fails when a sub-expression cannot become a pure Datum.

Trait Implementations§

Source§

impl Clone for Term

Source§

fn clone(&self) -> Term

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Term

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Term

Source§

impl From<Term> for Expr

Source§

fn from(term: Term) -> Self

Converts to this type from the input type.
Source§

impl Hash for Term

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Term

Source§

fn eq(&self, other: &Term) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Term

Source§

impl TryFrom<Expr> for Term

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(expr: Expr) -> Result<Self>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for Term

§

impl RefUnwindSafe for Term

§

impl Send for Term

§

impl Sync for Term

§

impl Unpin for Term

§

impl UnsafeUnpin for Term

§

impl UnwindSafe for Term

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.