Skip to content

Commit

Permalink
doc/ref/spec.md: revert to the old semantics of [k]: v
Browse files Browse the repository at this point in the history
As it turns out, the old semantics is quite frequently used.
Even though it is not hard to simulate the old semantics with
the proposed new one, it is still inconvenenient.

We do need the more JSON Schema-like semantics, though, as it
is hard to simulate with the old semantics.

The idea is now to allow `[...K]: V` for pattern constraints
to be applied to "additional" fields. So now any constraint
that applies to additional fields uses `...`.

Another advantage is thats, as we have not yet made the
transition to the new semantics, this eliminates a possibly
painful transition.

Change-Id: Iebd2af03e4929d058e4f3134d77d2071ef3ee82e
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/7942
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
  • Loading branch information
mpvl committed Dec 16, 2020
1 parent 85f8b46 commit f52a0ed
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions doc/ref/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -1050,8 +1050,13 @@ match that pattern.
When unifying structs `a` and `b`,
a pattern constraint `[p]: v` declared in `a`
defines that the value `v` should unify with any field in the resulting struct `c`
whose label unifies with pattern `p` and for which there exists no
field in `a` with the same label.
whose label unifies with pattern `p`.

<!-- TODO: Update grammar and support this.
A pattern constraints with a pattern preceded by `...` indicates
the pattern can only matches fields in `b` for which there
exists no field in `a` with the same label.
-->

Additionally, a _default constraint_, denoted `...value`, defines a value
to unify with any field for which there is no other declaration in a struct.
Expand Down

0 comments on commit f52a0ed

Please sign in to comment.