Expand description
Builtin methods, associated functions, and constructors.
Everything here is dispatched dynamically on a receiver value, a type name,
or a constructor name. The MVP has no method table derived from types yet,
so an arity or type mismatch is an ordinary RuntimeError that names the
method it came from.
What each builtin is — its parameters, its result, and whether its
receiver is var self — is cove_schema::builtins, two tables below
both this crate and the compiler: one for what is called on a receiver and
one for the constructors and assertions, which are called on nothing. This
module is the other half: the bodies, which have to be here because a body
reaches into a Value and cove-schema has no values. Every question a
name alone can answer is asked of the schema rather than answered twice —
which names are namespaces, which methods mutate, which names construct,
which assert, how many arguments each takes, and which receivers report a
length — and tests/builtin_schema.rs drives every entry in both tables
through a real interpreter, so a signature declared with no body behind it
fails a test rather than a program.
Traits§
- Callable
- How the builtins call back into the evaluator.
Functions§
- call_
assertion assert(condition: Bool) -> Result<Unit, Error>andassertEqual(actual: T, expected: T) -> Result<Unit, Error>.- call_
associated Vector.of(...)andInt.parse(...).- call_
constructor Ok(v),Err(e),Some(v),Error("message"),Shared(value).- call_
method - Dispatches
receiver.name(args)to a builtin method. - check_
live - A vector consumed by
freeze()is no longer usable. - free_
builtin - The builtins that are called on nothing: the constructors
Ok,Err,Some,Error, andShared, and the assertionsassertandassertEqual. - freeze
- Consumes uniquely owned vector storage and returns its elements as an
Arrayin O(1). - is_
builtin_ type - Type names a program may write as a namespace, such as
Vector.of. - is_
mutating_ method - The methods that take a
var selfreceiver and therefore need a mutable place at the call site. - no_
snapshot_ conformance - What a value that implements no
Snapshotconformance is refused with. - snapshot
- The independent copy
Snapshotmakes of a value that no declared conformance answers for. - spread_
needs_ a_ sequence - What a
...argument that is neither anArraynor aVectoris refused with.