-
Notifications
You must be signed in to change notification settings - Fork 36
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
Zero value for except_ref type? #55
Comments
It's coming with the reference type proposal. However, the long-term idea is that (most) future reference types will not include null (see e.g. the section on function refs), and that we have to find ways to cope with that anyway. It would be natural to not include null in the exception thing either. |
A reasonable 0 value for exceptions would be one where I like the idea of going along with whatever the reference type proposal comes up with. @rossberg - if there is no null, what are reference variables going to be initialized with? |
The most obvious solution would be that locals of non-defaultable types require an explicit initialiser. |
Ah, right. Of course, that means we have to add initializers, but I think that makes sense. I imagine we'll want to add more types in the future where a default value doesn't make sense. |
That just raises the question of "what is a reasonable explicit initializer for an |
Ah, good point. So it seems like no matter what we'll want a default value. Another option is to make sure no variable is read before it's assigned to as part of the Wasm module's validation phase. This is potentially expensive, but I suspect it's easier given that Wasm has only structured control flow. I don't really think this is the best idea though. If we add a 0 exception, what would rethrowing it mean? |
The simpler alternative is to introduce variable definitions with tighter scope, i.e., something let-like. That avoids both null and complicated initialisation checks. |
I think for exceptions,
|
You could also do it the other way around, because a branch out of the catch could take the ref as an arguments. |
We don't have |
Seems fine to allow null into the exception type as a stop-gap measure for now. But I would hope that we have something akin to let in time to restrict this before finalising this proposal. In particular, the same problem comes up with typed function refs, so we'll need a proper solution soon enough. |
Closing this, at least we have |
The Local Variables section of Semantics in the design repo says
Because
except_ref
type can be assigned to locals, we should have a zero value likenullref
forexcept_ref
type. Do we have it?The text was updated successfully, but these errors were encountered: