[wgsl] Define the void type - #712
Conversation
| The void type contains no values. | ||
| It is used where a type is required by the language but | ||
| where no values are produced or consumed. | ||
| For example, it is used for the return type of a function which does not produce a value. |
There was a problem hiding this comment.
Isn't this the only place where the void type can be used?
There was a problem hiding this comment.
Good question. I didn't want to lock it down too much, and we can revisit this.
In SPIR-V, an extended instruction can return void, e.g. OpenCL C has a "vstoren" builtin that maps to an extended instruction with result type of "void". See "vstoren" in https://www.khronos.org/registry/spir-v/specs/unified1/OpenCL.ExtendedInstructionSet.100.html
But the OpExtInst instruction always has a result type, and for that case it returns the void type.
There was a problem hiding this comment.
In the grammar itself, we only list it for the return type:
function_type_decl
: type_decl
| VOID
I don't think we have sufficiently strong evidence that Void needs to be used wider than this.
There was a problem hiding this comment.
Sorry for the late reply. I just thought of this.
We haven't written out the type rules just yet. There may be many uses of void as a type, e.g. as the type attributed to a statement such as a for loop. So there could be uses as a type but not in the grammar itself.
|
If void is just for 'nothing returned', we could consider moving towards the return-a-tuple syntax, and use |
No description provided.