Skip to content

Conversation

@alan-baker
Copy link
Contributor

  • Define function call and call site
  • Describe execution of function calls
  • Add rules for parameter matching
  • Updates funciton call statement and function call expression
  • Further restriction are still a TODO

* Define function call and call site
* Describe execution of function calls
* Add rules for parameter matching
* Updates funciton call statement and function call expression
* Further restriction are still a TODO
@alan-baker alan-baker added the wgsl WebGPU Shading Language Issues label Apr 21, 2021
@alan-baker alan-baker requested review from dneto0, kvark and litherum April 21, 2021 19:54
parameter).
* Control is transferred to the first statement in the called function
* The called function is executed
* When the called function finishes execution by either executing a return statement or reaching
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something is to be said about discard here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a note at the bottom. Discard bypasses the entire return stack.

Copy link
Contributor

@dneto0 dneto0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Some nits on the prose.

wgsl/index.bs Outdated
</pre>

A function call statement executes a [=function call=] where the called
function does not return value.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing "a": Should be "not return a value"

wgsl/index.bs Outdated

A function call statement executes a [=function call=] where the called
function does not return value.
If the called function returns a value, that value must be consumed (either
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'd avoid the parenthesis here.

wgsl/index.bs Outdated
When a function call is executed the following steps occur:
* Execution of the current function is suspended.
All [=function scope=] variables and constants maintain their current values.
* Storage is allocated to the function scope variable in the called function.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a missing word or something here. Suggest:

"Storage is allocated for each function scope variable in the called function."

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could use a note about initialization, as a reminder.

"Initialization occurs as described in [[#variables]]."

wgsl/index.bs Outdated
by matching the function call argument values by position the formal
parameters (e.g. the first argument is matched to the first formal
parameter).
* Control is transferred to the first statement in the called function
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End this bullet point sentence with a period.
Same for the next line.

wgsl/index.bs Outdated

The type of each argument must match the type of the matched formal parameter.
A value must be supplied for each formal parameter that is declared without a
default value.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no default values. If there's a missing parameter then you must have selected a different function in the first place.

So I suggest:

"The function call must supply the same number of argument values as there are formal parameters in the called function. Each argument value must have the same type as the corresponding formal parameter, by position."

I think this validation rule should be placed before the behavioural description. The behaviour doesn't make sense if the rule is violated.

wgsl/index.bs Outdated
Call sites are a [=dynamic context=].
As such, the same textual location may represent multiple call sites.

Note: default parameter values are only available for built-in functions. See
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say this isn't the case. Instead, "overloads" are distinct functions that use the same name.

For me a "default" parameter is something like C++ foo(int a =1);

wgsl/index.bs Outdated
Note: default parameter values are only available for built-in functions. See
[[#builtin-functions]].

Note: the current function will not resume execution if the called function or
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The".

@dneto0
Copy link
Contributor

dneto0 commented Apr 21, 2021

My instinct is we can avoid talking about "default" values for formal parameters, and that we should.

* move validation rules earlier
* don't describe default values
* fix typos
* add a comment about initialization
@github-actions
Copy link
Contributor

Previews, as seen when this build job started (507a69f):
WebGPU | IDL
WGSL
Explainer

Copy link
Contributor

@dneto0 dneto0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: please remove the stray "a"

wgsl/index.bs Outdated

The function call must supply the same number of argument values as there are
[=formal parameter|formal parameters=] in the called function.
Each argument value must a have the same type as the corresponding formal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove "a" in "must a have"

@dneto0 dneto0 merged commit 5963fc2 into gpuweb:main Apr 22, 2021
@alan-baker alan-baker deleted the function-calls branch August 23, 2021 19:32
ben-clayton pushed a commit to ben-clayton/gpuweb that referenced this pull request Sep 6, 2022
…eb#1651)

This is the last PR to simplify the names of the existing tests
with descriptions.

Issue: gpuweb#1618
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wgsl WebGPU Shading Language Issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants