This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Default value of WebAssembly.Global
#6
Comments
I probably agree that zero is nicer (== more useful for more programs), but this seems like the type of case that justifies the existence of NaN in the first place. I won't be able to attend the CG f2f next week but perhaps get this on the agenda for a quick poll? |
Make sure to ask which NaN, and which zero 😉 |
We discussed this at the April CG meeting, and decided to make the default value 0. @rossberg also presented on the js types proposal, where it would be more convenient to move the value initializer out of the descriptor, into a second argument:
This second argument, if omitted, will use the default value for the type. For the numeric types, that's 0, but for future nullable reference types it will be null. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I'm currently working on the v8 implementation of this proposal, and noticed that the current wording requires the default value of a
f32
orf64
WebAssembly.Global
to beNaN
.I believe this is because of the step
1. Let |v| be |descriptor|["value"]
, which makes|v|
undefined
, whichToWebAssemblyValue
converts toNaN
. This seems to be consistent with passing an undefined value to an exported function, but I think in this case it would be nicer to have the default be zero instead.Note that if an imported global has an undefined in the import object, a
LinkError
will be thrown instead:The text was updated successfully, but these errors were encountered: