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

[JavaScript] Add BigInt suffix and Numeric Separators #1294

Merged
merged 2 commits into from
Dec 1, 2017

Conversation

Thom1729
Copy link
Collaborator

@Thom1729 Thom1729 commented Nov 8, 2017

Implements the BigInt and Numeric Separators proposals. See #1269.

@Thom1729
Copy link
Collaborator Author

Thom1729 commented Nov 9, 2017

Based on #1049, do we want to add more specific scopes? For instance:

    0x12345n
//  ^^^^^^^^ constant.numeric.hex.js
//  ^^ punctuation.definition.numeric.hex.js
//         ^ storage.type.numeric.bigint.js

This would be a reasonably simple change, but it would clobber most of this PR.

@Thom1729
Copy link
Collaborator Author

Thom1729 commented Nov 9, 2017

Added punctuation and storage scopes from #1049. Also, the new tests got borked somehow; they're back, with a pile of fixes.

@wbond
Copy link
Member

wbond commented Nov 13, 2017

Awesome, I was actually about to ask if you could add these scopes. Thanks for the proactive changes!

@wbond
Copy link
Member

wbond commented Nov 13, 2017

One thing I noticed is that the scopes should be tweaked to: constant.numeric.integer.decimal, constant.numeric.integer.hexadecimal, constant.numeric.integer.octal, constant.numeric.float, etc.

@wbond
Copy link
Member

wbond commented Nov 13, 2017

Perhaps like #1292 we can split this into improvements that affect Babel or at least one browser and hold off on the bigint suffix for now?

@Thom1729
Copy link
Collaborator Author

Thom1729 commented Nov 13, 2017

The separators are implemented in Babel, and BigInt is in Stage 3 and on the fast track to acceptance. However, because it is not yet supported by Babel, we could conceivably cut it for now.

The standard JavaScript primitive numeric type is number, representing IEEE 754 double-precision floating point numbers. Even 0 and 0xff are floating-point literals. So historically, it might not have made sense to explicitly mark numeric literals as ...float, because every literal was a float. The new BigInt proposal introduces a second primitive numeric type, BigInt, representing arbitrary-precision integers. Literals like 0n represent true integers. Given that, our options are more or less as follows:

  1. Implement BigInt and mark literals as ...float and ...integer.
  2. Don't implement BigInt yet, but mark all existing literals as ...float.
  3. Don't make the distinction now, but add it when we implement BigInt.
  4. Don't make the distinction at all.

Option 2 has the drawback of appearing a little odd to the uninitiated, although when BigInt is implemented it would make more sense. That might be an argument in favor of Option 1. Option 3 is probably a bad idea; if we're changing the scopes now anyway, we may as well do it once.

@wbond
Copy link
Member

wbond commented Dec 1, 2017

Alright, that sounds reasonable to me. Since there isn't a distinction between int/float, let's leave the scopes as-is.

Thanks for your work on this.

@wbond wbond merged commit 3ebd282 into sublimehq:master Dec 1, 2017
@Thom1729 Thom1729 deleted the javascript-fancy-numbers branch May 14, 2018 19:19
deathaxe pushed a commit to deathaxe/sublime-packages that referenced this pull request Jun 9, 2019
[JavaScript] Add BigInt suffix and Numeric Separators
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants