Replies: 6 comments 2 replies
-
|
I completely failed to find this issue via search, as it doesn't mention the |
Beta Was this translation helpful? Give feedback.
-
|
Linking here to #3772 which discussed whether imported package values should be non-recursively closed or not. It's interesting to consider that if we did that, then package values themselves could be trivially used as closed schemas: Noting thought that with case 2 it's not exactly terrible to have to close the value imported; more a question of how often that needs to be done by the importer. |
Beta Was this translation helpful? Give feedback.
-
|
In light of Issue #4097, I propose a slight change to the "reclosing" rules in the spec: In fact, note that the reclosing rules were not defined in the spec at all. Now they are. I propose these reclosing rules make it in for v0.15, as they are kind of fundamental to this feature. |
Beta Was this translation helpful? Give feedback.
-
|
I was skeptical before I read the proposal, but this convinced me:
I also like |
Beta Was this translation helpful? Give feedback.
-
|
@mxey thanks for the feedback. Here is an updated spec with an alternative example of using New spec update: https://review.gerrithub.io/c/cue-lang/cue/+/1221642/21/doc/ref/spec.md N.B. we are adopting the convention that we have Gerrit CLs with the spec changes on "Hold" as long as an experiment is active. |
Beta Was this translation helpful? Give feedback.
-
|
Ok, I've read issue #4097, I've read the proposal details, I've had a play with the experiment, and I've refreshed my prior thinking on closedness. There are aspects that I like. For example the fact that But I am not a fan of how destructive Closedness can exist on any subtree of a struct. Closedness is policy: it allows you to state the effect of other fields in future unifications. For example: x: { a: int, b: close({c: 7})}
y: { a: 2, b: { d: _ }}
z: x & y
If we wanted to extend xʹ: {
x
b: e: int
}
z_ok: xʹ & {b: e: 12}
z_ko: xʹ & {b: f: 12}This use case is now not supported. Using @experiment(explicitopen)
x: { a: int, b: close({c: 7})}
xʹ: {
x...
b: e: int
}
z_ok: xʹ & {b: e: 12}
z_ko: xʹ & {b: f: 12} // this no longer errorsI'm not arguing in favour of the old syntax or any of the awkward semantics of the status quo. But I think there is a use case that's being dropped here. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
📋 Proposal Details:
Eliminate Embedding-Based Struct Opening Semantics
This proposal eliminates the implicit opening of closed structs through
embedding and introduces an explicit postfix
...operator forrecursively opening composite structs.
This change simplifies CUE's semantics, reduces user confusion, and enables
clearer expression of type extensibility patterns.
Full Proposal
The complete proposal with all technical details, examples, and implementation notes can be found in the proposal document.
How to Comment
Please provide feedback on this proposal:
Last updated: 2025-08-19 11:42:24 UTC
Beta Was this translation helpful? Give feedback.
All reactions