-
Notifications
You must be signed in to change notification settings - Fork 90
Switch (back) to multi-return, remove unit, s/expected/result/ #69
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
Co-authored-by: Peter Huene <[email protected]>
Co-authored-by: Peter Huene <[email protected]>
I just rebased this PR on top of #70 and made the analogous changes to WIT.md (s/unit// s/expected/result/). Three subjective choices that might be wrong and are thus worth calling out and discussing are:
|
…t' or 'functuple'
I'm curios: what is the motivation for removing Is it related to subtyping, simplifying the type model or language mapping constraints? I quite appreciated having an explicit unit type. How would one represent a union with a potential For example, in Assemblyscript: Without a dedicated For example, one possible mapping is using There are probably other examples of where this ambiguity could potentially be problematic. |
Of course I can understand that having a unit type is also problematic, because not every language has a clear notion of such a type. Would unit be Either way it would be nice if the docs contained a reasoning and motivation for some of the design choices. |
|
I suggest embracing the asymmetry in Wit. Wit syntax is all about human readability and convenience. While there is a mechanical symmetry, there is also an overwhelming practical asymmetry. In particular, From that perspective, I suggest omitting the
This implies special-case syntax for 0 and 1. The forms with |
I'm in the 40-60% range on this question, so no strong opinions here, but just to dig into the reasoning for the asymmetry a bit:
I agree that the vast majority of functions should be returning a |
For what it's worth, I'm all for explicitness. I've come to appreciate having to type a little more to satisfy a compiler versus accidentally leaving off important details. I would much rather unambiguously specify an empty result set than have the compiler figure it out. In fact, I'd prefer if the compiler straight-up told me that I'm missing a return type instead of quietly rolling over it. |
WASI itself is expecting to have functions with no return values, in the upcoming logging API. It's much less common, but does happen. That said, My main suggestion here is that we don't need the special cases for 0 or 1 parameters. Those would risk confusion and uninteresting variety, which is a more important concern than syntactic symmetry here. And consequently, we don't need whitespace between |
If we remove the "implicit |
The circumstances that make a single unnamed return value a useful special case don't seem to apply to parameters in the same way, so my suggestion is to deemphasize this special case in the wit syntax for parameters. Also, omitting the parens in a param list gives the appearance of a different kind of function. I suggest the syntax |
I suppose it's a matter of perspective, but in the presence of multi-return, it does feel like the same circumstances apply to both: if we say that we always want to have parens around params, then it seems surprising to have a different rationale applied to results. (It made sense for single-return, of course; but the context here is updating WIT to stay in lock-step with multi-return in the component model.) |
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 good to me!
Thanks for the review! |
This PR switches back to multi-return and, for the reasons outlined in #41, makes several associated changes:
unit
is removed (empty return can be used instead)variant
andexpected
case payloads are changed tolists of valuescontain either 0 or 1valtype
expected
is renamed toresult