BinOpKind

Enum BinOpKind 

Source
pub enum BinOpKind {
    Plus,
    Minus,
    Times,
    Eq,
    CellSet,
    Cons,
    IsCode,
    Log,
    App,
}
Expand description

Binary primitive operators that share the same shape:

  • eval e1 → v1
  • eval e2 → v2
  • dispatch on (v1, v2)

The dispatch differs per op (arithmetic vs equality vs cons-build), but the operand sequencing is identical.

Not in this enum: LiftRef. Although LiftRef takes two Exps, its dispatch on v1 happens before e2 is evaluated — if v1 is Code, e2 must be evaluated inside a reify scope, not normally. LiftRef has its own dedicated continuations (Cont::LiftRefDispatch, Cont::LiftRefForceCode).

Variants§

§

Plus

+ — Cst+Cst → Cst, Code+Code → reflect Plus, else TypeError

§

Minus

- — Cst−Cst → Cst, Code−Code → reflect Minus, else TypeError

§

Times

* — Cst×Cst → Cst, Code×Code → reflect Times, else TypeError

§

Eq

eq? — any pair → Cst(0|1), Code+Code → reflect Eq

§

CellSet

cell-set! — Cell×any → write (returns written value), Code×Code → reflect CellSet, else TypeError

§

Cons

cons — any → Tup, never staged (pairs always run-time data).

Cons lives in BinOpKind to reuse the BinOpRight/BinOpFinish operand-sequencing machinery — it’s the only variant here that has no Code-dispatch branch and is not stage-polymorphic at all. The dispatcher just unconditionally builds a Val::Tup; stage reflection for cons happens one level up, when a Val::Tup of two Val::Code is fed to lift (see eval/mod.rs::lift’s Tup arm). Resist the urge to add a fake Code arm to dispatch_binop for symmetry — the paper’s λ↑↓ does not stage cons directly.

§

IsCode

code? — Cst(0|1) on second arg’s variant; if first is Code, reflect IsCode (second must then be Code or TypeError)

§

Log

log — first=Code → stage the log; else IO-print second. Both operands are evaluated regardless of the dispatch (unlike LiftRef), so the standard binop sequencing fits.

§

App

Function application (f x) — Clo+_ → tail-jump body; Code+Code → reflect App; else TypeError. This is the only binop where one outcome is Mode::Eval (tail jump) rather than a pure Val producer; App is therefore special-cased in step_apply and not dispatched through dispatch_binop.

Trait Implementations§

Source§

impl Clone for BinOpKind

Source§

fn clone(&self) -> BinOpKind

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for BinOpKind

Source§

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

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

impl PartialEq for BinOpKind

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 Copy for BinOpKind

Source§

impl Eq for BinOpKind

Source§

impl StructuralPartialEq for BinOpKind

Auto Trait Implementations§

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.