Correct schema spec and note different usages of @name. Closes #31.

This commit is contained in:
Tony Garnock-Jones 2023-10-29 15:20:09 +01:00
parent ee0f9a79fd
commit 55deeea343
1 changed files with 16 additions and 10 deletions

View File

@ -4,7 +4,7 @@ title: "Preserves Schema"
---
Tony Garnock-Jones <tonyg@leastfixedpoint.com>
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.