Concepts and primitives

Two intrinsic namespaces carry types no package declares (semantics.md §4). They sit on opposite sides of lowering.

Concepts: what the source wrote

@concepts$ names the types of things that have no storage of their own:

  • the literals — @concepts$Int, @concepts$Float, @concepts$String, @concepts$Array<T, n>, @concepts$Map<K, V>;
  • a block argument — @concepts$Block.

A concept is a type for checking only. A literal reaches a storage type through an implicit constructor, which the TST writes down as a node of its own (semantics.md D9), and a block never becomes a value at all: the verb that takes it is expanded at its call site (lowering.md L11). So no concept reaches the CGT.

Primitives: what the machine stores

@primitives$ names storage: U8, I32, I64, F32, F64, Bool, Unit, String, Array<T, n>, ArrayRef<T, n>, List<T>, ListRef<T>, the byte search’s ByteSet, and the worker pool’s WorkerPool<T, S, E> and EventSource. Packages build types on them — an Int can be a struct around an @primitives$I64, as types.md §2.6 describes core’s — or write them directly, under an alias if they like. A primitive has no operators; the @operators$ functions are what a package’s own operators are written over.

Lowering gives each primitive its machine layout (lowering.md L5): @primitives$I64 is an i64, I32 an i32, F64 a double, F32 a float, Bool an i1, and String, List and ListRef are handles whose payload lives in the dynamic region, a WorkerPool is a handle to its runtime object, as a foreign handle is, and an EventSource is its interval’s i64. A struct around one primitive has that primitive’s layout, so such an Int costs what an i64 costs.

Why the line is there

Concepts let a literal or a block be checked before it is known where it will be stored: 20 is an Integer until a parameter or a field declares which integer type it becomes. Primitives are the opposite: they say exactly what the machine holds, and nothing about how the source spelled it. Keeping them apart means the front end reports errors in the terms the author wrote, and codegen sees only types with a layout.