Expand description
The five type names the compiler knows as scalars, and the one it knows beside them.
Int, Float, Bool, Char and String are scalar: each is declared in
Zelkova like any other type, and the compiler additionally knows the
representation each target gives it. Scalar
types is the rule; this module is the
list it names.
A scalar is known by the qualified name of its declaration — package, module and
name — and never by its spelling (DEC-15 decision
1).
A module declaring its own Int declares an ordinary type that shares three letters
with a scalar, and every phase treats it as one — which is why Scalar::declares
takes a QualName and there is no entry point taking a bare
Name. The same goes for a whole package: a dependency’s own
Basics declaring type Int = Int declares Basics.Int of that package, and the
five scalars are declared in zelkova-core only.
§Why the list lives here and not in the typer
The typer is the only reader today: typer::canonical_type_to_typer_type maps
four of the five onto its own literal types, and BOOL names the union an if
condition is checked against. The list is nonetheless a fact about
the language rather than about type inference, and the same five names answer
questions the typer never asks — which names a module underneath Basics receives
without an import, and which declarations may name nothing but themselves. It sits
beside the phases for the same reason
default_imports does.
Structs§
- Scalar
- One scalar type: the module of
zelkova-coreits declaration lives in, and the name that declaration writes.
Constants§
- BOOL
Basics.Bool, which is a scalar and an ordinary union at once: the compiler knows its representation and nothing about its structure, soTrueandFalsestay constructors like any others.- CHAR
Char.Char.- FLOAT
Basics.Float.- INT
Basics.Int.- OPAQUE_
SCALARS - The four scalars whose declaration is opaque (
DEC-15decision 2): nothing in the language constructs or inspects a value of one, so each declares only its own name and contributes no constructor. - POSITION
Basics.Position: the type a derivation handsdifferedandatConstructorfor a constructor’s place in its declaration.- SCALARS
- The five scalar types, in the order Scalar types lists them.
- STRING
String.String.
Functions§
- opaque_
scalar_ of - The opaque scalar
namedeclares, if it declares one —NoneforBOOLeven thoughscalar_ofwould answer it, sinceBOOLis not inOPAQUE_SCALARS. - scalar_
of - The scalar
namedeclares, if it declares one.