Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Support for not() builtin #571

Closed
myitcv opened this issue Oct 27, 2020 · 2 comments
Closed

Support for not() builtin #571

myitcv opened this issue Oct 27, 2020 · 2 comments
Labels
builtin FeatureRequest New feature or request
Milestone

Comments

@myitcv
Copy link
Contributor

myitcv commented Oct 27, 2020

Noting an offline conversation with @mpvl and @rogpeppe

Is your feature request related to a problem? Please describe.

Consider:

Steps: [name=string]: #Step | 
    { [#LangCode]: #Step } | 
    { [#ScenarioName]: #Step } | 
    { [#LangCode]: [#ScenarioName]: #Step } | 
    { [#ScenarioName]: [#LangCode]: #Step }

#LangCode = "en" | "fr" // etc

Scenarios: [name=XYZ]: #Scenario

#ScenarioName: or([ for name, _ in Scenarios {name}])

The declaration of Steps as written is only possible if we can constrain a #Scenario name in some way (shown with XYZ here) to be any string that is not a valid #LangCode.

Describe the solution you'd like

Potentially something like:

not(or(#LangCode))

Describe alternatives you've considered

A negative specification using _|_ does work:

Scenarios: [#LangCode]: _|_

However, it leads to more misleading error messages.

Additional context

@myitcv
Copy link
Contributor Author

myitcv commented Oct 28, 2020

Noting an offline conversation: that not() is effectively syntactic sugar around constrain():

x: not(y)

// is equivalent to

x: constrain(x & y == _|_)

Which might mean that not() is not required (assuming "nice" error messages can be inferred from such negative constraints).

@cueckoo
Copy link

cueckoo commented Jul 3, 2021

This issue has been migrated to cue-lang/cue#571.

For more details about CUE's migration to a new home, please see cue-lang/cue#1078.

@cueckoo cueckoo closed this as completed Jul 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
builtin FeatureRequest New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants