-
Notifications
You must be signed in to change notification settings - Fork 695
Streamline tableswitch notation #443
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
Conversation
This has the same bug I found in the earlier version here, that Also, what is the intended relationship between the s-expression language and the binary format? The current My assumption is that the place for streamlined syntax is either the official text syntax or a macro-assembler layer, with the purpose of the s-expression syntax being to make the binary format's structure and concepts readable to humans working at that level. This is because the binary format is the thing that most producers and consumers will be communicating through in practice, so its structure and concepts are things that most producers and consumers will need to be aware of, so humans working at this level will need to be aware of them too. |
Right, a fallthrough to a Text syntax or a macro assembler do not solve the main problem with the current form, namely the significant (and unnecessary) semantic complication it introduces on the AST level. The prose glosses over that entirely, but the way the internal case labels would work is entirely different from other labels. In fact, it violates the very statement (at least as written) in the following paragraph, about labels having to be bound by enclosing constructs. Pretending they are regular labels requires to partition the label namespace into two types. The seeming notational liberty also raises questions like #439. Wouldn't you agree it's preferable to avoid all these issues by construction? |
I do agree. In fact, all these issues are avoided by construction in the binary format that I expect this design to translate into. I initially overlooked the issue in #439 because I was mainly thinking in terms of the binary format and how this will be decoded, and this problem doesn't arise there (unless we choose to make the design to include it, but I don't think we need to). I do agree that the current wording uses "label" in a confusing way, and can be generally simplified. I've now submitted #444 to propose a simpler, clearer wording which also avoids #439 by construction. It does so at the cost of introducing a new concept, but it's a simple concept that actually has an even closer affinity to what I'm envisioning in the binary encoding. What is the intended relationship between the s-expression language and the binary format? |
The way I view it, there are 3 relevant levels of code format:
S-expressions are merely a direct textual representation of the AST, so should mirror its structure. With respect to switch, the presence of a concrete jump table is primarily relevant for (3) -- and of course, its semantics is designed to enable that. A (more abstract form of) table probably also is the best choice for (2) and even (1). But that doesn't mean that the isomorphism between them has to be pointwise. |
One way to measure the match of the semantic structure is the degree to which it achieves its results by construction, which is mentioned above. An explicit table structure is dense and zero-based by construction. Specifying the default target as an attribute of the |
Closing this, since there is no consensus and I found a way to spec tableswitch with only desugaring and no complication to the kernel. |
As discussed in #427, this streamlines the notation of
tableswitch
such that it is written with just one table instead of two and avoids auxiliary labels. It does not change what can be expressed. Advantages of this notation are:This matches what is currently implemented in WebAssembly/spec#153.