Skip to main content

Builtin

Enum Builtin 

Source
pub enum Builtin {
Show 41 variants IntAdd, IntSub, IntMul, IntPow, IntDivrem, IntFor, ErrRaise, ErrCatch, Match, ListSize, ListGet, ListAppend, ListWith, ListSplit, Eq, MapNil, MapWith, MapGet, MapGets, MapFor, MapMerge, MapCat, MapWithout, MapSize, IntStr, StrPack, StrUnpack, SymFrom, SymStr, ModName, Proto, ObjNew, ObjValue, Int, Str, Sym, List, Map, Err, Mod, Fun,
}
Expand description

A native builtin operation in the reserved __ namespace. All are curried; see the integers section of docs/elly-spec.md.

Variants§

§

IntAdd

§

IntSub

§

IntMul

§

IntPow

§

IntDivrem

§

IntFor

§

ErrRaise

§

ErrCatch

§

Match

§

ListSize

§

ListGet

§

ListAppend

§

ListWith

§

ListSplit

§

Eq

§

MapNil

§

MapWith

§

MapGet

§

MapGets

§

MapFor

§

MapMerge

§

MapCat

§

MapWithout

§

MapSize

§

IntStr

§

StrPack

§

StrUnpack

§

SymFrom

§

SymStr

§

ModName

§

Proto

__proto v — the prototype of any value: an object’s own, and the builtin module for every other kind. A bare builtin, like __eq and __match, because it cuts across kinds rather than belonging to one. It is total, so it is the classifier as <Proto> and the objects design are written against, and it grants nothing: a module value carries no authority to construct with it or to unwrap against it.

§

ObjNew

The object constructor, (prototype, payload). Not reachable by name: it is absent from from_name and from ALL, and the only route to a value of it is the __new leaf, which supplies the prototype from the module the body is written in. So there is no way to mint an object of a type you are not writing.

§

ObjValue

The object payload reader, (prototype, object) — reached the same one way, through __value, and refusing an object whose prototype is not the one supplied (.foreign_object), so a method cannot unwrap a value that merely passed through it.

§

Int

§

Str

§

Sym

§

List

§

Map

§

Err

§

Mod

§

Fun

__Fun, the prototype of every callable kind — a closure, a builtin, and a host function. It has no items yet: docs/todo/elly-function-arity.md is what gives it nargs / nfree / nrets. It exists for the totality of Proto, which is enough on its own to make it a module.

Implementations§

Source§

impl Builtin

Source

pub const ALL: &'static [Builtin]

Every nameable builtin, in declaration order — the source of truth for tooling that needs to enumerate the __ namespace (e.g. the bench suite’s coverage check). Keep in sync with the enum: a new variant forces an arm in the exhaustive name/arity matches just below, which sit next to this list.

ObjNew and ObjValue are deliberately absent: no name reaches them, only the home-module leaves, so listing them would claim a __ name that does not resolve. They still render under one (name) — a partially-applied __new has to say what it is.

Source

pub fn from_name(name: &str) -> Option<Builtin>

Resolve a __-name to its builtin, if any: a bare name (__eq, __match), a builtin module (__Int), or a module member in the dotted form name renders (__Int.add).

A <sym> token can never contain a . — the dot is a Muon sigil — so the dotted case is not what the parser hits; it is how tooling, and the Builtin::ALL round-trip, read a rendered name back. The parser reaches a member through member instead, once the resolver has folded __Int .add (see resolve.rs).

Source

pub fn from_alias(name: &str) -> Option<Builtin>

The builtin module this bare alias names, if any: Int__Int. The aliases are the resolver’s bottom tier — the language’s prelude — consulted after everything a name could be lexically bound to, so they shadow by construction (see resolve.rs).

Source

pub fn member(self, name: &str) -> Option<Builtin>

The item name of this builtin module, if it has one: __Int’s add is __Int.add is Builtin::IntAdd. None for a name the module does not hold, and for any builtin that is not a module — which is what makes it safe to ask on every callee of a call spine (see the fold in resolve.rs).

Source

pub fn proto_kind(self) -> Option<TyKind>

The value kind this builtin module is the prototype of, if it is one — what lets an as <Proto> pattern naming it compile to a discriminant test (see crate::ProtoRef).

None for anything that is not a module, and for __Err: it is a namespace of operations, and no value answers __proto with it, so as Err is rejected rather than compiled into a check that cannot hold.

Source

pub fn name(self) -> &'static str

The reserved __-name this builtin is referenced by: a module member is dotted (__Int.add), which is how it is written and how it renders.

Trait Implementations§

Source§

impl Clone for Builtin

Source§

fn clone(&self) -> Builtin

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 Builtin

Source§

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

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

impl Hash for Builtin

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 Ord for Builtin

Source§

fn cmp(&self, other: &Builtin) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Builtin

Source§

fn eq(&self, other: &Builtin) -> 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 PartialOrd for Builtin

Source§

fn partial_cmp(&self, other: &Builtin) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for Builtin

Source§

impl Eq for Builtin

Source§

impl StructuralPartialEq for Builtin

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.