-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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: Add new BigInt primitive #1515
Conversation
Should this land after #1135? |
@annevk Yes. |
I've got a bunch of suggested changes. I think it might be best to submit them as a PR against caiolima:big-int. |
@jmdyck That's great to hear. Looking forward to seeing your PR. |
Done: caiolima#3 |
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.
LGTM!
It'd be great to have reviews from the editors for this PR ahead of the June 2019 TC39 meeting, where Caio and I plan to propose BigInt for Stage 4. cc @ljharb @zenparsing
@littledan FYI, there are new changes from caiolima#4. |
Formerly, the procedure for applying ToNumber to the String type was spread over three widely-separated prose paragraphs in two different clauses. This commit brings all that together, expresses it as an actual algorithm, and gives it the name StringToNumber. Similarly for the value of a NumericLiteral, here expressed as the syntax-directed operation NumericValue. This commit should provide better integration-points for PR tc39#1515 (BigInt).
Formerly, the procedure for applying ToNumber to the String type was spread over three widely-separated prose paragraphs in two different clauses. This commit brings all that together, expresses it as an actual algorithm, and gives it the name StringToNumber. Similarly for the value of a NumericLiteral, here expressed as the syntax-directed operation NumericValue. This commit should provide better integration-points for PR tc39#1515 (BigInt).
<li>If _base_ < 0 and _base_ is finite and _exponent_ is finite and _exponent_ is not an integer, the result is *NaN*.</li> | ||
</ul> | ||
<emu-note> | ||
<p>The result of _base_ `**` _exponent_ when _base_ is *1* or *-1* and _exponent_ is *+Infinity* or *-Infinity* differs from IEEE 754-2008. The first edition of ECMAScript specified a result of *NaN* for this operation, whereas later versions of IEEE 754-2008 specified *1*. The historical ECMAScript behaviour is preserved for compatibility reasons.</p> |
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.
commenting here to note the interaction with #1609
Given that you identify the concern as non-blocking, and you haven't made another suggestion, would it make sense to land this PR and be open to other editorial alternatives? |
Thanks for the approval, BTW! |
It’ll need approval from the other editor first. My approval means that yes, it will land once it has approval from the full editor group. |
|
||
<emu-clause id="sec-numeric-types-bigint-subtract"> | ||
<h1>BigInt::subtract ( _x_, _y_ )</h1> | ||
<p>The abstract operation BigInt::subtract with two arguments _x_ and _y_ of type BigInt returns the BigInt representing the difference _x_ minus _y_.</p> |
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.
<p>The abstract operation BigInt::subtract with two arguments _x_ and _y_ of type BigInt returns the BigInt representing the difference _x_ minus _y_.</p> | |
<p>The abstract operation BigInt::subtract with two arguments _x_ and _y_ of type BigInt returns the BigInt value that represents the difference _x_ minus _y_.</p> |
... for consistency with my last commit. (I missed it because I was only looking for "a BigInt representing".)
@zenparsing is there anything else we need to do into this PR to get it merged? |
This PR includes changes over current ECMA262 spec text to include a new primitive type called `BigInt`. This includes all changes necessary to integrate this new primitive in the language. It also includes changes on TypedArray, introducing `BigInt64Array` and `BigUint64Array` Changes during PR review: - Make NumberToBigInt(...) a sub-clause of BigInt(...) and put "Runtime Semantics:" in the header, otherwise it looks too much like a built-in function. (Analogous to Function() and CreateDynamicFunction()) - Rewrite the characteristics of the BigInt prototype object as a bulleted list. - Change 9x "of BigInt type" to "of type BigInt". Also, 1x "of BigInt" to "of type BigInt". - In the BigInt:: ops, change a few '0' to '*0n*'. - For some BigInt:: ops, change the preamble to a complete sentence - Rename "BitwiseOp" as "BigIntBitwiseOp" for symmetry with NumberBitwiseOp. Also, add an 'aoid' attribute to the clause. - Replace "ToString Applied to the BigInt Type" with "BigIntToString" - Rename 'NumericLiteralBase' to 'NonDecimalIntegerLiteral'. It more clearly expresses what it is, and it fits nicely with 'DecimalIntegerLiteral'. - Put 'thisBigIntValue' in a <dfn> element. - Mention '_littleEndian_' in preambles for setBigInt64, setBigUint64 - Tweak pseudocode in Atomics.compareExchange - Reference new productions from Annex A. - Reproduce changes to 'NumericLiteral' in Annex B. - Replace <a> element with <emu-xref> - In "Numeric Type Operations" table, split "Value and Purpose" into 3 columns - Add ::toString() as a numeric type operation. - In BigInt::toString, invoke BigInt::toString directly, rather than via ToString. - Changing the grammar for BigInt literals to disallow them for Annex-B non-octal digits (tc39/proposal-bigint#208) - Relocate new property-clauses (Specifically, properties of DataView.prototype and the BigInt constructor.) - Move some new abstract op clauses. - Delete NumberToString: you have Number::toString; ditto BigIntToString and BigInt::toString. - In the "Type Conversion" clause, rather than simply putting all the new abstract operations at the end, move them to more logical locations. - Change "TypedArrayType" to "ElementType". "TypedArrayType" (and "TypedArray type") suggests one of the TypedArray types, where we're really talking about one of the TypedArray *element* types. - Add 'oldids' attributes - Reference DecimalBigIntegerLiteral from Annex A - Use NonDecimalIntegerLiteral in StrNumericLiteral Co-authored-by: Caio Lima <[email protected]> Co-authored-by: Michael Dyck <[email protected]> Co-authored-by: Michael[tm] Smith <[email protected]>
@ljharb and @zenparsing Thanks a lot for the review! @jmdyck and @littledan thx a lot for the fixes and reviews as well. |
- Let -> Set - Eliminate otherwise-assertions (per tc39#1559) - Change '?' to '!', because ::subtract can't return an abrupt completion. - Fix bug: '_v_' should be '_value_' - Fix bug: `_arrayTypeName_` not defined ... in Atomics.{store,wait,notify}. (In Atomics.store, it does get defined in step 5, but needs to be defined before the reference in step 3.) (In Atomics.wait, the undefined reference is in step 11, but by defining it earlier, it can also be used in the current step 3.) (In Atomics.notify, the undefined reference is in step 7.)
This PR is include changes to integrate tc39/proposal-bigint into ECMA262 text. It contains changes on:
BigInt64Array
andBigUint64Array
as new types ofTypedArray
.DataView
operations to support new types.Proposal author: Daniel Ehrenberg and Brendan Eich