-
Notifications
You must be signed in to change notification settings - Fork 165
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
Consider renaming numeric types to match ECMAScript typed arrays #843
Comments
Do the IDL types actually have the same semantics as the WebASM types? Because if not, naming them the same thing is a bit dangerous. I do agree that it would be nice if the size were just explicit. But whether changing every single web spec for this is worthwhile is less clear. One option would be to add the sized typedefs explicitly and see whether people actually use them... |
Correction: WebAssembly uses Apart from that, they have mostly identical semantics, especially because the WebAssembly binding for ECMAScript is defined in WebIDL.
The only difference is that WebAssembly doesn’t currently allow passing |
I like this idea and with @saschanaz's rewriting tool this might even be feasible (though typedefs might be good transition help nevertheless). (One problem it would resolve is that IDL and Infra conflict on byte. What Infra calls byte IDL currently calls octet.) |
We could also merge Alternatively, change the That would fix the current issue with |
While I'm in principle for this change, the resultant IDL files in #856 now look like a strange and jarring mixture between the C/JavaScript style and the more concise Rust/WASM style… My proposal would be to use |
Now that extended attributes can modify the type a [LegacyUnrestricted] extended attribute would probably work and might be nicer. We should probably make that change separately (and first) though. |
I don't think unrestricted is legacy. But also it should remain opt-in; it's intentional that spec authors not have to think about Infinity/NaN cases when writing their specs unless they explicitly opt in to doing so. |
That’s why I went with |
Currently, WebIDL uses C names for number types.
This doesn’t match either ECMAScript or WebAssembly, where the former just uses the generic IEEE 754 64‑bit
number
type, and the latter usess*
for signed integers,u*
for unsigned integers andf*
for IEEE 754 floating point numbers.I suggest applying the following renaming for integers:
byte
int8
i8
s8
octet
uint8
u8
u8
short
int16
i16
s16
unsigned short
uint16
u16
u16
long
int32
i32
s32
unsigned long
uint32
u32
u32
long long
int64
i64
s64
unsigned long long
uint64
u64
u64
And the following for floating‑point numbers:
float
float32
f32
unrestricted float
[Unrestricted] float32
[Unrestricted] f32
double
float64
f64
unrestricted double
[Unrestricted] float64
[Unrestricted] f64
Unlike the current names, where several programming languages use
long
for different integer sizes:long
int32
int64
int64
By using the
int*
/sint*
,uint*
andfloat*
forms, it becomes clear at first glance what the integer size is.See also:
The text was updated successfully, but these errors were encountered: