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
impl Builtin
Sourcepub const ALL: &'static [Builtin]
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.
Sourcepub fn from_name(name: &str) -> Option<Builtin>
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).
Sourcepub fn from_alias(name: &str) -> Option<Builtin>
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).
Sourcepub fn member(self, name: &str) -> Option<Builtin>
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).
Sourcepub fn proto_kind(self) -> Option<TyKind>
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.