From 202d92d237b269bb642d549634f460501079024a Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Sun, 15 Oct 2023 01:16:46 +0200 Subject: [PATCH] Rationale note about annotation binary syntax --- preserves-binary.md | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/preserves-binary.md b/preserves-binary.md index 8ada4d2..1b24cfd 100644 --- a/preserves-binary.md +++ b/preserves-binary.md @@ -140,11 +140,26 @@ represent the denoted object, prefixed with `[0x86]`. «@W V» = [0x85] ++ «W» «V» -Each annotation `W` precedes the `Value` `V` it annotates; both `W` and -`V` *MAY* themselves be further annotated. Implementations *SHOULD* -default to omitting annotations from `Repr`s. See [examples in the +Each annotation `W` precedes the `Value` `V` it +annotates.[^annotation-syntax-rationale] Both `W` and `V` *MAY* +themselves be further annotated. Implementations *SHOULD* default to +omitting annotations from `Repr`s. See [examples in the appendix](#annotation-examples). + [^annotation-syntax-rationale]: **Rationale.** The syntax for + annotated values is unlike any other compound syntax defined here. + It allows parsers to *statelessly* skip annotations: while `0x85` is + the next input byte, skip it, skip a single `Repr`, and then try + again; otherwise, parse the input stream as usual. + + By contrast, one might imagine using a parenthesized syntax like the syntax of + compound data. In that case, parsers would have to remember + information about nesting of annotations. This would not necessarily + be an issue for recursive ("DOM"-like) parsers, but streaming + ("SAX"-like) parsers would have to either take on complexity + internally or force it on their clients, even when those clients did + not care about annotations. + ## Security Considerations **Annotations.** In modes where a `Value` is being read while