-
Notifications
You must be signed in to change notification settings - Fork 302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
spec/comprehension: if clause is missing else #111
Comments
Original reply by @mpvl in cuelang/cue#111 (comment) It is not missing, it was deliberately omitted. I’m not entirely against adding it, but only after getting more data and experience with comprehensions and seeing how they develop. Conditional expression tend to lead to awful configurations, and although comprehensions are grammatically not expressions, they are getting close and just might develop into them. |
Original reply by @mpvl in cuelang/cue#111 (comment) BTW, note that the above could be approximated as:
Disjunctions will often be a good approach for more complicated structural alternatives. A more likely language extension, which would also be useful for JSON schema compatibility would be to allow |
Original reply by @mpvl in cuelang/cue#111 (comment) You could even fully simulate
where only the else block is not marked as a default. Note you can have multiple defaults, which makes sense to use if there is a discriminator field, like in this case. |
Original reply by @xinau in cuelang/cue#111 (comment) @mpvl Thanks for the input. |
Original reply by @seh in cuelang/cue#111 (comment)
I discovered today that this example works up until the "foo" field has a value that's a string or an int. If it matches either of the first two disjunction alternatives, we have to ensure that it doesn't match the third as well. We need something like the following in the third alternative:
|
List it before Slack, on the basis we want to push people towards GH Discussions (better surfaces questions and answers etc)
Originally opened by @xinau in cuelang/cue#111
atm. the only way to implement a
else
is to add the sameif
clause and negating the expressionwhile this works, it feels strange from a user perspective coming from other languages.
I also checked the spec and it seems to be missing https://github.com/cuelang/cue/blob/master/doc/ref/spec.md#comprehensions
The text was updated successfully, but these errors were encountered: