-
Notifications
You must be signed in to change notification settings - Fork 353
Describe function calls #1651
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
Describe function calls #1651
Conversation
alan-baker
commented
Apr 21, 2021
- 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
| 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this 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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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."
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The".
|
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
dneto0
left a comment
There was a problem hiding this 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 |
There was a problem hiding this comment.
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"
…eb#1651) This is the last PR to simplify the names of the existing tests with descriptions. Issue: gpuweb#1618