Print ordering

This commit is contained in:
Tony Garnock-Jones 2023-03-22 13:35:46 +01:00
parent 18dd532df2
commit fe9d836942
1 changed files with 10 additions and 1 deletions

View File

@ -54,7 +54,10 @@ label-`Value` followed by its field-`Value`s.
curly-brace-enclosed colon-separated pairs of values. `Set`s are
written as values enclosed by the tokens `#{` and
`}`.[^printing-collections] It is an error for a set to contain
duplicate elements or for a dictionary to contain duplicate keys.
duplicate elements or for a dictionary to contain duplicate keys. When
printing sets and dictionaries, implementations *SHOULD* order
elements resp. keys with respect to the [total order over
`Value`s](preserves.html#total-order).[^rationale-print-ordering]
Sequence = "[" *Value ws "]"
Dictionary = "{" *(Value ws ":" Value) ws "}"
@ -68,6 +71,12 @@ duplicate elements or for a dictionary to contain duplicate keys.
commas separating, and commas terminating elements or key/value
pairs within a collection.
[^rationale-print-ordering]: **Rationale.** Consistently printing
the elements of unordered collections in some arbitrary but stable
order helps, for example, keep diffs small and somewhat meaningful
when Preserves values are pretty-printed to text documents under
source control.
`Boolean`s are the simple literal strings `#t` and `#f` for true and
false, respectively.