Renderingen-US

Experimental through version 1. Version 0 was alpha. This is the first language release: the interface is relatively stable, not frozen. Nothing is promised stable until version 2.

record

Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.

Labeled ad-hoc record type: construction, .name access, objectPattern, and holes.

Aliases: record

Syntax: record<label: type, …> { label = value }

Category#

type

Examples#

radix/corpus/reference/keyword/ratio/ratio.fab (canonical · keyword)#

Labeled ad-hoc record type: construction, .name access, objectPattern, and holes.

# =============================================================================
# record — Labeled ad-hoc aggregate (promoted Type::Record).
# =============================================================================
#
# What this teaches:
#   • labeled type args: record<g: f32, w: int>
#   • construction: record<g: f32, w: int> { g = 1.0, w = 2 }
#     (the constructor head is the file's own locale spelling: `record` in
#     this English file; the canonical Latin `ratio` head is accepted only in
#     a Latin file — unit 047eef65)
#   • .name access: point.g (labels only — no bracket form)
#   • objectPattern destructuring: let {g, w} ← point
#   • partial + rest: let {loss, rest leftover} ← metrics
#   • element holes: record<g: _> solved from the construction witness
#   • binary cup element: record<g: string ∪ none>
#
# Reject teaching rows (comments only; these must not become stage-3 inputs):
#   • positional access attempt: point[0] / point.0
#   • missing label: record<f32>
#   • ∪ slot: record<g: ∪>
#   • record ↦ class fence: r ↦ P  (use reconstruction P { g = r.g })
#
# See also: class, rest, tuple
# =============================================================================

main {
    # Construction and .name access.
    # Same-locale surface: the en type-head `record` claims the constructor
    # slot too (map-in-both, unit 047eef65); the canonical Latin `ratio`
    # head is rejected in an English file.
    let record<g: f32, w: int> point ← record<g: f32, w: int> { g = 1.0, w = 2 }
    print point.g
    print point.w

    # Element hole solved from the construction witness.
    let record<g: _, w: int> hole ← record<g: f32, w: int> { g = 1.0, w = 2 }
    print hole.g + 0.0
    print hole.w

    # A wanted union element is a binary cup, not ∪ in the slot.
    let record<g: string ∪ none> cup ← record<g: string ∪ none> { g = "x" }
    print cup.g

    # objectPattern binds by label.
    let {g, w} ← point
    print g
    print w

    # Partial by-label binding; rest is the unbound sub-record.
    let record<loss: f32, steps: int> metrics ← record<loss: f32, steps: int> { loss = 3.0, steps = 4 }
    let {loss, rest leftover} ← metrics
    print loss
    print leftover.steps
}

Expected output:

1.0
2
1.0
2
x
1.0
2
3.0
4