From 55deeea343987bdab88675caffd31f26584ee58f Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Sun, 29 Oct 2023 15:20:09 +0100 Subject: [PATCH] Correct schema spec and note different usages of @name. Closes #31. --- preserves-schema.md | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/preserves-schema.md b/preserves-schema.md index eb5dbda..e791236 100644 --- a/preserves-schema.md +++ b/preserves-schema.md @@ -4,7 +4,7 @@ title: "Preserves Schema" --- Tony Garnock-Jones -February 2023. Version 0.3.2. +October 2023. Version 0.3.3. [abnf]: https://tools.ietf.org/html/rfc7405 @@ -207,20 +207,26 @@ definition-unique *name*. The name is used to uniquely label the alternative's host-language representation (for example, a subclass, or a member of a tagged union type). -A variant name can either be given explicitly as `@name` (see discussion -of `NamedPattern` below) or inferred. It can only be inferred from the -label of a record pattern, from the name of a reference to another -definition, or from the text of a "sufficiently identifierlike" literal -pattern - one that matches a string, symbol, number or boolean: +A variant name can either be given explicitly as `@name` or +inferred.[^variant-names-unlike-binding-names] It can only be inferred +from the label of a record pattern, from the name of a reference to +another definition, or from the text of a "sufficiently identifierlike" +literal pattern - one that matches a string, symbol, number or boolean: - AltPattern = "@" id SimplePattern + AltPattern = "@" id Pattern / "<" id PatternSequence ">" / Ref / LiteralPattern -- with a side condition -A host language will likely use the same ordering of its types as -specified by the schema. It is therefore recommended to specify first -the alternative best suited as a default initialization value (if +[^variant-names-unlike-binding-names]: Note that explicitly-given + *variant* names are unlike *binding* names in that binding names give + rise to a field in the record type for a definition, while variant + names are used as labels for alternatives in a sum type for a + definition. + +A host language will likely use the same ordering of variants in a sum +type as specified by the schema. It is therefore recommended to specify +first the alternative best suited as a default initialization value (if there is any). ### Intersection definitions.