You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
doc/ref/spec.md: alternative definitions for closedness and friends
This CL changes the meaning of `[x]: y` and `...` fields and
closedness with the following objectives:
- Incorporate experience of usability of defintions and closedness
- Simplify the rules of closedness to simplifiy both
its usages and implementation
- Make it (far) easier to express JSON Schema in CUE.
- Allow closedness to be expressed in terms of CUE itself
The expressability of JSON Schema in CUE seems important as
this seems to becoming one of the major application domains
of CUE. Aside from that, it is a general win for the language
as it results in more expressability without loss of generality:
the old CUE semantics can easily be simulated by enclosing
bulk optional fields in curly braces (the current `cue fmt` and
`cue fix` currently do this rewrite).
The changes to bulk optional fields (now pattern constraints) bring
them in line with the definition of "patternProperties" of JSON Schema.
The same holds for the `...` notation, which now maps to
additional properties. To allow for a complete one-to-one mapping,
the spec now also allows for `...T`. This brings it in line with the
semantics for lists.
Coincidentally, the new JSON Schema semantics allows closed structs
to be defined in terms of CUE itself (using `..._|_`).
In addition, the new simplified definition aims to simplify
implementation and incorporate user feedback to make definitions and
closed structs more intuitive.
As a consequence of the simplified defintions, let expressions can no
longer be used to circumvent closedness. The relaxed rules around
closedness and the earlier reintroduction of hidden fields make this
an acceptable compromise.
Transition plan:
The new definition changes the meaning of existing syntax. The plan
is to first rewrite the old semantics into equivalent CUE that will
give the same results with the new interpretation. This is already
implemented with cue fix and cue fmt.
The next step is to prohibit any usage of bulk optional fields that
will mean something different with the new syntax (CL pending).
Finally, the new behavior is implemented by the new evaluator.
Change-Id: I2617597ea4a973d8987239ead4e62d51002c622b
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/6260
Reviewed-by: Marcel van Lohuizen <[email protected]>
0 commit comments