Schemas

This page defines the schema-level vocabulary used by the reference.

A schema kind is a primary schema family. A schema group is a named set of schemas defined by a criterion. Exact field layouts, callable signatures, and other schema-specific details remain outside these broad categories.

Schema Kinds

Kind Common sources Description
Block [...] Compile-time block schema. Meta.
Code codeRef, importFunction, exportFunction Callable code schema whose exact signature belongs to the schema.
Cond DEBUG, FALSE, TRUE, predicate results Condition schema used by branching and logical condition operations.
Dict {...} with named fields Struct schema with named items.
Int8 Integer literals with i8 8-bit signed whole-number schema kind.
Int16 Integer literals with i16 16-bit signed whole-number schema kind.
Int32 Integer literals with default integer syntax or i32 32-bit signed whole-number schema kind.
Int64 Integer literals with i64 64-bit signed whole-number schema kind.
Intx Integer literals with ix Pointer-width signed whole-number schema kind.
List array, uniform (...), uniform unnamed {...} Struct schema with unnamed items of one shared item schema.
Nat8 Natural literals with n8 8-bit unsigned whole-number schema kind.
Nat16 Natural literals with n16 16-bit unsigned whole-number schema kind.
Nat32 Natural literals with n32 32-bit unsigned whole-number schema kind.
Nat64 Natural literals with n64 64-bit unsigned whole-number schema kind.
Natx Natural literals with nx Pointer-width unsigned whole-number schema kind.
Real32 Real literals with r32 32-bit floating-point schema kind.
Real64 Real literals with default real syntax or r64 64-bit floating-point schema kind.
Ref @NAME, .@NAME, @, fieldRead Reference schema kind. The schema defines the target schema and mutability.
Text "TEXT", «TEXT», & UTF-8 text schema kind.
Tuple Non-uniform (...), empty (), non-uniform unnamed {...} Struct schema with unnamed items whose item schemas are not required to match. The empty value () is a Tuple.

Schema Groups

A schema group is a named set of schemas defined by a criterion. Some groups are unions of schema kinds, while others are defined by broader schema properties.

Group Criterion Where it matters
Int Schemas whose kind is Int8, Int16, Int32, Int64, or Intx. Signed Int operations and comparisons.
Meta Schemas of zero size. Compile-time-only objects and schema-level operations. Tested by virtual?.
Nat Schemas whose kind is Nat8, Nat16, Nat32, Nat64, or Natx. Nat operations, counts, and address-like values.
Number Schemas in the Whole or Real groups. Arithmetic, numeric comparisons, casts, and numeric transforms.
Real Schemas whose kind is Real32 or Real64. Floating-point transforms such as cos, log, and sqrt.
Ref-like Schemas whose kind is Ref, Code, or Text. isRef and fieldIsRef.
Scalar Schemas in the Cond kind or the Number group. Scalar value operations and comparisons.
In-place Schemas whose values are stored directly at their own runtime location. Default runtime data path. Numbers, Cond, and non-Meta Struct schemas are In-place. Contained fields may still be Ref-like; the term describes the outer schema, not recursive field contents.
Struct Schemas whose kind is Dict, List, or Tuple. Struct schema operations such as isCombined, fieldCount, fieldIndex, fieldName, and has.
Whole Schemas in the Int or Nat groups. Bitwise operators and shifts such as and, lshift, rshift, xor, and ~.

Common operational consequences

The groups above are schema-level sets. The recurring consequences below summarize common implications of those groups.

Example

Schema kinds and groups

{} 0 {} [
  "-- schema kinds --" printCompilerMessage
  [] schemaName printStack _:;
  {x: 0;} schemaName printStack _:;
  (1 2) schemaName printStack _:;
  0n32 schemaName printStack _:;
  "hi" schemaName printStack _:;

  "-- schema groups --" printCompilerMessage
  {x: 0;} isCombined printStack _:;
  (1 2) isCombined printStack _:;
  [] code? printStack _:;
  {} () {} codeRef codeRef? printStack _:;
  () virtual? printStack _:;
  0n32 managed? printStack _:;

  0
] "main" exportFunction

Expected Output During Compilation

-- schema kinds --
"«test.mpl» 3 3 Block"
"{x: Int32;}"
"Int32 2 array"
"Nat32"
"Text"
-- schema groups --
TRUE
TRUE
TRUE
TRUE
TRUE
FALSE

What remains schema-specific

Where to continue