-
Notifications
You must be signed in to change notification settings - Fork 45
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
Have all enums have "undefined" as value 0? #45
Comments
I don't think it's worth mimicking the empty dictionary here, but I do buy the argument about making some stuff optional. How about this compromise: we switch all enum values to start with |
Great idea. I'll do that, but it will take some time because there's a lot of reordering to do :) |
Should we:
I'm tentatively in favor of 2. We can switch to 1 later. I'm not exactly sure what Dawn does right now, but I'm pretty sure we don't implement the IDL's defaulting, at least in most cases. |
In Dawn we try to implement the IDL defaulting as much as possible. Though maybe we missed a couple things. In general it's nice if defaulting can be equivalent to zero-initialization as much as possible, so IMHO option 1 would be ideal, with Undefined in every single enum to be future proof when other additions to the header use the enum. |
OK with me. I do like having the defaulting there, though because of the various sentinel UNDEFINED values zero-initialization unfortunately doesn't work in general (#158 (comment)). But it does make it somewhat easier to use zero-initialization and initialize only the fields which don't default to 0 (probably going to be common practice even after we add INIT macros). |
Another question came up when I started implementing this: what should we do with output/status enums?
|
More questions. Do we actually need these? AFAICT neither of these really needs to have default values.
I looked in Dawn, and we use these, but I don't think we need them. |
No opinion about |
webgpu.h meeting: We should implement the defaulting in the C API (and have It means we don't have to inject WebGPU validation errors when you use It also means we can translate the EDIT(2024-06): posting the full minutes because I didn't capture everything in my summary:
|
Dec 21 meeting
|
webgpu-native/webgpu-headers#45 (comment) Bug: dawn:2224 Change-Id: Ib7b8df5ebf0ca7458045a130fb8ee8ad4b3995a7 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/166900 Commit-Queue: Kai Ninomiya <[email protected]> Kokoro: Kokoro <[email protected]> Reviewed-by: Loko Kung <[email protected]>
We did the last of these in Dawn, but also did it for the output enums. In my opinion, it's marginally nicer to also have output enums start from 1 for consistency. It will avoid problems if there is an unexpected case where an enum becomes used in an input in the future. |
Jul 18 meeting:
|
This was fixed in #364, I forgot to link it. |
This would allow zero-initializing to be as close as an empty dictionnary as possible in JS. It would also help if the JS API decide in after version 1 to make some enum members optional for example when adding defaults.
The text was updated successfully, but these errors were encountered: