Consider renaming numeric types to match ECMAScript typed arrays #843
Open
Description
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 uses s*
for signed integers, u*
for unsigned integers and f*
for IEEE 754 floating point numbers.
I suggest applying the following renaming for integers:
Current (WebIDL) | Proposed (ECMAScript‑style) | Proposed (Rust‑style) | Proposed (WASM‑style) |
---|---|---|---|
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:
Current (WebIDL) | Proposed (ECMAScript‑style) | Proposed (Rust/WASM‑style) |
---|---|---|
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:
Language | long |
---|---|
C | int32 |
C# | int64 |
Java | int64 |
By using the int*
/sint*
, uint*
and float*
forms, it becomes clear at first glance what the integer size is.
See also:
Metadata
Assignees
Labels
No labels