Rules
링크Derived 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.
이유
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.
Examples
링크Render declared fields and an empty record
링크import 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 {}
기대 결과
기대 결과
실행을 마칩니다. 종료 코드 0.
Pair { z: 3, a: Topaz }Empty {}
Reject a record without Show conformance
링크record Pair { z: int, a: string }let text = Show.show(Pair { z: 3, a: "Topaz" })
표준 출력 없음.기대 결과
기대 결과
거절 단계 check. 종료 코드가 0이 아닙니다.
protocol-call-argument-does-not-conform at
derived-show-bad.tpz:2:22