Records and pattern matching (Closes #156) #165

Merged
robertismo merged 1 commit from 156-records into master 2026-10-04 15:24:53 +00:00
Owner

Language: defrecord registers a constructor + field accessors; match does record-shape destructuring, wildcards, and else clauses; records are a first-class value kind.

Engine: canonical loan (id amount term defaultn), bond and offer (price size turns-left) record types with builtin accessors (loan-id, loan-amount, loan-term, loan-default, bond-price/size/turns-left, offer-price/size/turns-left) and predicates (loan?, bond?, offer?). market-loans, market-bonds, and bank-offers now return records.

Brains: all five mains and the five spec brains migrated off nth indexing onto the accessors. bank-loans and bank-bond-assets/debts stay tuples until #158 defines the book shapes.

Verified: a full seeded spectate against master produces byte-identical output — the migration is behavior-preserving, and the magic-index class of bug is closed.

Language: defrecord registers a constructor + field accessors; match does record-shape destructuring, wildcards, and else clauses; records are a first-class value kind. Engine: canonical loan (id amount term defaultn), bond and offer (price size turns-left) record types with builtin accessors (loan-id, loan-amount, loan-term, loan-default, bond-price/size/turns-left, offer-price/size/turns-left) and predicates (loan?, bond?, offer?). market-loans, market-bonds, and bank-offers now return records. Brains: all five mains and the five spec brains migrated off nth indexing onto the accessors. bank-loans and bank-bond-assets/debts stay tuples until #158 defines the book shapes. Verified: a full seeded spectate against master produces byte-identical output — the migration is behavior-preserving, and the magic-index class of bug is closed.
Records and pattern matching (Closes #156)
All checks were successful
build / build (push) Successful in 26s
250933295a
Language:
- defrecord: (defrecord point (x y)) registers the constructor and
  the point-x / point-y accessors in the current env
- match: (match subject (pattern body...) ...) with record-shape
  patterns (loan id amount term defaultn), bare-symbol wildcards, and
  else clauses; the subject is evaluated once
- a new "record" value kind, self-evaluating, with a readable String

Engine:
- canonical record types: loan (id amount term defaultn), bond and
  offer (price size turns-left), registered as language builtins with
  accessors (loan-id, loan-amount, loan-term, loan-default,
  bond-price/size/turns-left, offer-price/size/turns-left) and
  predicates (loan?, bond?, offer?)
- market-loans, market-bonds, and bank-offers now return records
  instead of index tuples

Brains: all five mains and the five spec brains migrated off nth
tuple indexing onto the accessors (the die-frequency, shelf, and
book walks included). bank-loans and bank-bond-assets/debts remain
tuples for now — those are the #158 domain-API shapes.

Behavior-preserving: a full seeded spectate against master produces
byte-identical output. The magic-index class of bug is closed.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Winnie/bankwars!165
No description provided.