Rules
LinkDerived record representation
For a record that derives Show, Show. returns its record name and fields in declaration order. A nonempty record uses Name { field: value, field: value }; an empty record uses Name {}. Each field uses the standard value rendering, so string fields appear without added quotes. A record without a Show conformance is rejected with TPZ5522. A manual Show implementation supplies its own method result.
Why
The record name and field names expose the value's structure. Declaration order makes the display stable across construction sites, and nested values use the shared renderer.
Source evidence
- builtin_protocol_dispatch at
151141d7bb44· 246-269 - render_into nominal record at
151141d7bb44· 306-329 - render_into scalar values at
151141d7bb44· 169-179 - gateUserProtocolCall at
151141d7bb44· 1029-1050
Examples
LinkRender declared fields and an empty record
Linkimport std.iorecord Pair derives Show { z: int, a: string }record Empty derives Show {}io.writeLine(Show.show(Pair { a: "Topaz", z: 3 }))io.writeLine(Show.show(Empty {}))
Pair { z: 3, a: Topaz }
Empty {}
Expected result
Expected result
Execution completes. Exit code 0.
Pair { z: 3, a: Topaz }Empty {}
Source evidence
- builtin_protocol_dispatch at
151141d7bb44· 246-269 - render_into nominal record at
151141d7bb44· 306-329 - render_into scalar values at
151141d7bb44· 169-179 - gateUserProtocolCall at
151141d7bb44· 1029-1050
Reject a record without Show conformance
Linkrecord Pair { z: int, a: string }let text = Show.show(Pair { z: 3, a: "Topaz" })
No stdout.
Expected result
Expected result
Rejection during check. Nonzero exit.
TPZ5522protocol-call-argument-does-not-conform atderived-show-bad.tpz:2:22
Source evidence
- builtin_protocol_dispatch at
151141d7bb44· 246-269 - render_into nominal record at
151141d7bb44· 306-329 - render_into scalar values at
151141d7bb44· 169-179 - gateUserProtocolCall at
151141d7bb44· 1029-1050