Skip to content
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

Support for not() builtin #571

Open
cueckoo opened this issue Jul 3, 2021 · 2 comments
Open

Support for not() builtin #571

cueckoo opened this issue Jul 3, 2021 · 2 comments
Labels
builtin FeatureRequest New feature or request

Comments

@cueckoo
Copy link
Collaborator

cueckoo commented Jul 3, 2021

Originally opened by @myitcv in cuelang/cue#571

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

@cueckoo cueckoo added builtin FeatureRequest New feature or request labels Jul 3, 2021
@cueckoo cueckoo added this to the v0.4.x milestone Jul 3, 2021
@cueckoo
Copy link
Collaborator Author

cueckoo commented Jul 3, 2021

Original reply by @myitcv in cuelang/cue#571 (comment)

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).

@myitcv
Copy link
Member

myitcv commented Jun 20, 2023

As part of the recent issue garden, we are focussing on non-feature requests. As such, I'm removing the milestone on this feature request. We will revisit feature requests in a later pass, at which point we will start to milestone and prioritise new features (in addition to those that we are already working on).

Noting however that this is covered (almost entirely) by #943.

@myitcv myitcv removed this from the v0.4.x milestone Jun 20, 2023
@mvdan mvdan removed the zGarden label Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builtin FeatureRequest New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants