Skip to content

Optional constraints proposal #25

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

juliusikkala
Copy link
Contributor

Closes #18. Based on shader-slang/slang#7201 (comment). Implementation ongoing in shader-slang/slang#7422.

@csyonghe do I also add you as a co-author? The syntax is entirely based on your comments.

@juliusikkala
Copy link
Contributor Author

Regarding syntax, opinions on where optional? If the optionality was attached to the type instead, like ?IThing or maybe IThing etc., it'd be less verbose and allow the short-hand syntax f<T: maybe IThing>(). It would also work in lists, like where T: IThing, maybe IAnotherThing, while the current syntax in the proposal needs separate where lines to do that. On the other hand, I feel that the optionality is a feature of the constraint and not the supertype, so in that sense it feels more "right" for the optionality marker to not be attached to the type.

(small anecdote; I've typo'd "where optional" as "where optionally" roughly 50% of the time so far 😄)

@csyonghe
Copy link
Contributor

I am open to supporting T: maybe IThing as a syntax if we find it to be convenient, but as you pointed out, optionality is an orthogonal concept to the kind of constraints, so we will need a general syntax for it anyways that will work for e.g. type equality constraint, value constraint(in the future) etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optional witnesses
2 participants