This commit is contained in:
Tony Garnock-Jones 2021-05-31 11:48:52 +02:00
parent 947b816a57
commit a44884d9f5
1 changed files with 8 additions and 3 deletions

View File

@ -179,7 +179,7 @@ are *merged* together.
#### Experimental.
Intersections are an experimental feature. They can be used to express
*optional dictionary entries*:
*optional dictionary entries*:[^not-ideal-optional-encoding]
MyDict = {a: int, b: string} & @c MaybeC .
MaybeC = @present {c: symbol} / @absent {} .
@ -188,6 +188,11 @@ It is not yet clear whether they pull their weight. In particular, the
semantics of serializing a value defined by intersection are not
completely clear.
[^not-ideal-optional-encoding]: This encoding is not ideal. Given a
term `{a: 1, b: "", c: sym}`, it will yield a `present` result,
and given `{a: 1, b: ""}`, will yield an `absent` result; but
`absent` will also result from `{a: 1, b: "", c: "notasymbol"}`.
### Patterns.
Pattern = SimplePattern / CompoundPattern
@ -262,8 +267,8 @@ A record pattern matches an input record. It may be specified as a
record with a literal in the label position, or as a quoted `<<rec>
... >` record:
RecordPattern = "<" value *(NamedPattern) ">"
/ "<<rec>" NamedPattern *(NamedPattern) ">"
RecordPattern = "<<rec>" NamedPattern *(NamedPattern) ">"
/ "<" value *(NamedPattern) ">"
A tuple pattern matches a fixed-length sequence with specific patterns
in each position. A variable tuple pattern is the same, but with an