Skip to main content

Module builtins

Module builtins 

Source
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> and assertEqual(actual: T, expected: T) -> Result<Unit, Error>.
call_associated
Vector.of(...) and Int.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, and Shared, and the assertions assert and assertEqual.
freeze
Consumes uniquely owned vector storage and returns its elements as an Array in 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 self receiver and therefore need a mutable place at the call site.
no_snapshot_conformance
What a value that implements no Snapshot conformance is refused with.
snapshot
The independent copy Snapshot makes of a value that no declared conformance answers for.
spread_needs_a_sequence
What a ... argument that is neither an Array nor a Vector is refused with.