Skip to content
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

Extends Name Section w/ Type & Field #415

Merged
merged 4 commits into from
Sep 8, 2023
Merged

Conversation

ashleynh
Copy link
Contributor

This PR updates the spec to add additional subsections for type and field within the custom name section. struct.get and struct.set also updated to indicate that their field indices are of type fieldidx, instead of u32. As a result, the metavariable representation was updated from i (integers) to y (indices).

Closes #193

Copy link
Member

@tlively tlively left a comment

Choose a reason for hiding this comment

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

LGTM. Would like a review from @rossberg as well.

@tlively tlively mentioned this pull request Aug 24, 2023
53 tasks
Copy link
Member

@rossberg rossberg left a comment

Choose a reason for hiding this comment

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

Note that field offsets are different in nature from other indices: in programming language terms they are numeric "labels" (in the record sense), whereas all other indices are numeric "variables". The difference is somewhat technical, though (has to do with how binding works and what can be renamed/shifted how), so I can live with calling them fieldidx.

document/core/appendix/custom.rst Show resolved Hide resolved
document/core/appendix/custom.rst Show resolved Hide resolved
document/core/syntax/modules.rst Show resolved Hide resolved
Co-authored-by: Andreas Rossberg <rossberg@mpi-sws.org>
@ashleynh
Copy link
Contributor Author

ashleynh commented Sep 6, 2023

Thanks for taking a look @rossberg! Can you expand on the technical differences w.r.t. binding and renames/shifts? Would calling it fieldOffsetIdx be preferred? We could add a note calling out the how they are numeric labels in the record sense.

@rossberg
Copy link
Member

rossberg commented Sep 6, 2023

No worries, I think the name is fine. The technicalities aren't easily explained in a couple of sentences, but roughly, for variables, use site and definition site are connected by scoping, i.e., you'll look up a variable in the current scope chain. Labels on the other hand are tied to, and looked up in, the type of some operand. Multiple labels of the same name can be used in the same scope while referring to different definitions (or sometimes, do not even need a definition). When you get down to something like lambda calculus, one consequence is that variables are freely renameable (and substitutable), while labels are not. But I'm digressing, not sure this is helpful... :)

@ashleynh
Copy link
Contributor Author

ashleynh commented Sep 7, 2023

Very helpful explanation, thank you!

@tlively tlively merged commit abae97d into WebAssembly:main Sep 8, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extending the Name section for struct fields
3 participants