-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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: Permit serialization of BigInt #3480
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the same order that the JavaScript specification will use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't find a list containing these three types in the JavaScript specification. The definition of == contains "String, Number, BigInt, or Symbol" but I didn't really give it any thought when I inserted BigInt in that position.
Should we have a total order of JS primitive types, and whenever we have a list, sort them by that order? What should be this total order? I'd like to defer these advanced editorial questions to the JS spec community's more experienced editorialists, e.g., @jmdyck
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about the order of the section 6.1 subsections.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Speaking of which, is the fact that we omit Symbol here a bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it seems we made a decision to throw on symbols. I'm not sure why, but they are quite different from other primitives, so maybe it makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A: Undefined, Null, Boolean, Number, String, Symbol, Object
B: Undefined, Null, Boolean, Number, Symbol, String
C: Undefined, Null, Boolean, String, Symbol, Number, Object
D: Undefined, Null, Boolean, Number, String, Symbol, Object
E: Undefined, Null, Boolean, Number, String, Symbol, Object
F: Undefined, Null, Boolean, Number, String, Symbol, Object
G: Undefined, Null, Boolean, Number, String, Symbol, Object
H: Undefined, Null, Boolean, Number, String, Symbol, Object
I: Undefined, Null, Boolean, String, Symbol, Number, Object
J: Undefined, Null, Boolean, Number, String, Symbol, Object
So a fair bit of consistency, but also some variation.
About the only benefit I can think of for a consistent order is that it makes it easier to check by eye that some list (set of cases) is complete. Mind you, this benefit would increase as more types are added to the language.
About the only disadvantage I can think of is that if you're doing a case analysis, it might make more sense to the reader to describe the handling of Type X before that for Type Y, and those orderings might not be consistent over the whole spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't remember from who, but I remember hearing some interest in extending structured clone to Symbols. My impression was that it was left out because it'd be somewhat complicated to make the proper global registry so that if you postMessage the symbol around multiple ways, you get the same one (e.g., sending S from A -> B -> C and also A -> C directly, you'd hope to get the same S').
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jmdyck Where do you think BigInt should be inserted in the list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjacent to Number, presumably, but I'm not sure about before or after.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's say BigInt goes after Number, unless someone has a preference otherwise.