Skip to content
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

Normative: Rename numeric types to match ECMAScript typed arrays #856

Closed
wants to merge 10 commits into from

Conversation

ExE-Boss
Copy link
Contributor

@ExE-Boss ExE-Boss commented Mar 17, 2020

Since there was support for #843, I decided to go ahead with opening a PR for this.

I decided to go with i* for signed integers because it’s what browser engines and the Rust programming language use and due to ECMAScript providing implicit support for 32‑bit signed integers using the binary OR operator, but none for unsigned integers:

let numI32 = (num | 0); // Converts `num` to a 32-bit signed integer

ECMAScript Arrays also restrict the length to a positive 32‑bit signed integer.

Depends on:


Resolves #843

🔗 PR Preview


Preview | Diff

index.bs Outdated
Comment on lines 8356 to 8458
Promise<void> delay(unrestricted double ms);
Promise<void> delay(unrestricted f64 ms);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that I had to revert this due to unrestricted f64 currently being a syntax error.

Copy link
Member

@saschanaz saschanaz Mar 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this mean the PR should wait for the parser to be updated first?

Copy link
Contributor Author

@ExE-Boss ExE-Boss Mar 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably merge this as‑is, since this PR also defines "aliases" for:

// Not actually implemented using `typedef`s, this is just for illustration:
typedef (i8) byte;
typedef (i16) short;
typedef (i32) long;
typedef (i64) long long;

typedef (u8) octet;
typedef (u16) unsigned short;
typedef (u32) unsigned long;
typedef (u64) unsigned long long;

typedef (f32) float;
typedef (unrestricted f32) unrestricted float;
typedef (f64) double;
typedef (unrestricted f64) unrestricted double;

We’d just have to remember to convert unrestricted double to unrestricted f64 once the parser is updated.

Copy link
Member

@saschanaz saschanaz Mar 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK an identifier can't contain a whitespace and thus it can't be like typedef (i64) long long;.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s why this isn’t actually implemented using typedefs, that is just for illustration, the actual aliases are defined as:

For legacy compatibility, byte is to be treated as an alias for i8, similar to:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, missed that part, sorry 😅

index.bs Outdated
Comment on lines 8383 to 8485
Promise<void> validatedDelay(unrestricted double ms);
Promise<void> validatedDelay(unrestricted f64 ms);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

index.bs Outdated
Comment on lines 8409 to 8511
Promise<any> addDelay(Promise<any> promise, unrestricted double ms);
Promise<any> addDelay(Promise<any> promise, unrestricted f64 ms);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@ExE-Boss ExE-Boss changed the title feat: Rename numeric types to match Rust/WASM feat: Rename numeric types to match ECMAScript typed arrays Mar 18, 2020
@ExE-Boss ExE-Boss changed the title feat: Rename numeric types to match ECMAScript typed arrays Normative: Rename numeric types to match ECMAScript typed arrays Sep 6, 2020
@domenic
Copy link
Member

domenic commented Aug 2, 2021

Let's close this for now until the discussion in #843 (and related #857) comes to a firmer conclusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Consider renaming numeric types to match ECMAScript typed arrays
3 participants