Skip to content

Describe function calls#1651

Merged
dneto0 merged 3 commits into
gpuweb:mainfrom
alan-baker:function-calls
Apr 22, 2021
Merged

Describe function calls#1651
dneto0 merged 3 commits into
gpuweb:mainfrom
alan-baker:function-calls

Conversation

@alan-baker

Copy link
Copy Markdown
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
Comment thread wgsl/index.bs
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
Copy Markdown
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
Copy Markdown
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.

@dneto0 dneto0 left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread wgsl/index.bs Outdated
</pre>

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

Copy link
Copy Markdown
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"

Comment thread 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
Copy Markdown
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.

Comment thread 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
Copy Markdown
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
Copy Markdown
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]]."

Comment thread 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
Copy Markdown
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.

Comment thread 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
Copy Markdown
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.

Comment thread 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
Copy Markdown
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);

Comment thread 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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"The".

@dneto0

dneto0 commented Apr 21, 2021

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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

@dneto0 dneto0 left a comment

Copy link
Copy Markdown
Contributor

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"

Comment thread 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
Copy Markdown
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