From fe9d8369424bc69bae58f66adffe9f056a688eb6 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Wed, 22 Mar 2023 13:35:46 +0100 Subject: [PATCH] Print ordering --- preserves-text.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/preserves-text.md b/preserves-text.md index a6e9ca4..d9eb5ad 100644 --- a/preserves-text.md +++ b/preserves-text.md @@ -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.