You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 3, 2021. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 3, 2021. It is now read-only.
To form a forward-compatible basis for the JS API type reflection proposal, I'm proposing two minor changes to the signature of the JS-side Global constructor:
move the value parameter out of the descriptor (already done),
rename the type field to something else, e.g., value or content (similar to the element in table descriptors).
Tothether these make the descriptor into a suitable representation of a Wasm global type, which would be compatible with other occurrences of this type in the proposed reflection API.
(The motivation for renaming the type field is that the whole descriptor represents the "type" of the global, so the field should be given a more specific name.)
Hm, seems a bit redundant, as it is part of a type description already. The API doesn't say elementType or parameterTypes either. I'd pick a name that captures what thing the field classifies, not what its own (meta)type is.
OK, so by that argument it should be value, since elemtype -> element. But I think value is a confusing name:
let g1 = new WebAssembly.Global({value: 100}); // Error!
let g2 = new WebAssembly.Global({value: 'i32'}, 100); // OK
g2.value // => 100
WebAssembly.Global.type(g2).value // => 'i32'
I agree 'value' is confusing. The name should have 'type' in it. 'contentType'? (Personally I think 'type' is unambiguous and that the motivation is on the weak side, but any clear alternative is probably OK.)
Note that it is part of a type already. With the JS type reflection proposal, type would lead to import.type.type, which is odd. Even import.type.valueType would be an awkward redundancy.
I see the possible confusion with value, so how about content? That is the closest analogue to element or parameters.
The expression import.type.type does make the redundancy more apparent. I kindof like element because it doesn't have the "is this the value or the value's type?" ambiguity of value and content. Also, once reference-types are fully realized, Globals are basically just cheap, single-element tables.
Activity
binji commentedon Apr 26, 2018
maybe
valueType? Or are we planning on adding non-valuetype globals?rossberg commentedon Apr 26, 2018
Hm, seems a bit redundant, as it is part of a type description already. The API doesn't say elementType or parameterTypes either. I'd pick a name that captures what thing the field classifies, not what its own (meta)type is.
binji commentedon Apr 26, 2018
OK, so by that argument it should be
value, sinceelemtype->element. But I thinkvalueis a confusing name:lars-t-hansen commentedon May 2, 2018
I agree 'value' is confusing. The name should have 'type' in it. 'contentType'? (Personally I think 'type' is unambiguous and that the motivation is on the weak side, but any clear alternative is probably OK.)
rossberg commentedon May 2, 2018
Note that it is part of a type already. With the JS type reflection proposal,
typewould lead toimport.type.type, which is odd. Evenimport.type.valueTypewould be an awkward redundancy.I see the possible confusion with
value, so how aboutcontent? That is the closest analogue toelementorparameters.binji commentedon May 10, 2018
Trying out
content:I still think
valueTypelooks the nicest, even if it does have the odd redundancy:lukewagner commentedon May 15, 2018
The expression
import.type.typedoes make the redundancy more apparent. I kindof likeelementbecause it doesn't have the "is this the value or the value's type?" ambiguity ofvalueandcontent. Also, once reference-types are fully realized,Globals are basically just cheap, single-element tables.binji commentedon May 15, 2018
We discussed this in the May 15th CG meeting and decided to use
value.ericprud commentedon Sep 5, 2018
Does the decision mentioned above close this issue?
binji commentedon Sep 5, 2018
Yes, closing.