Editorial: Replace Number-specific term "finite" with "finite Number"#3911
Editorial: Replace Number-specific term "finite" with "finite Number"#3911gibson042 wants to merge 8 commits into
Conversation
...fixing inappropriate auto-linking for uses of "finite" as a colloquial term Fixes tc39#3840
|
The rendered spec preview for this PR is available as a single page at https://tc39.es/ecma262/pr/3911 and as multiple pages at https://tc39.es/ecma262/pr/3911/multipage . |
| 1. If _value_ is a Number, then | ||
| 1. If _value_ is finite, return ! ToString(_value_). | ||
| 1. If _value_ is a finite Number, return ! ToString(_value_). |
There was a problem hiding this comment.
Alternatively:
| 1. If _value_ is a Number, then | |
| 1. If _value_ is finite, return ! ToString(_value_). | |
| 1. If _value_ is a finite Number, return ! ToString(_value_). | |
| 1. If _value_ is a finite Number, return ! ToString(_value_). | |
| 1. If _value_ is a Number, return *"null"*. |
But either one is fine.
michaelficarra
left a comment
There was a problem hiding this comment.
Changes LGTM otherwise, but I haven't checked that all the remaining uses of the term "finite" are still appropriate yet.
| @@ -33068,7 +33068,7 @@ <h1>Number.prototype.toFixed ( _fractionDigits_ )</h1> | |||
| 1. Assert: If _fractionDigits_ is *undefined*, then _fractionCount_ is 0. | |||
| 1. If _fractionCount_ is not finite, throw a *RangeError* exception. | |||
There was a problem hiding this comment.
This is the result of ToIntegerOrInfinity, it's be clearer to say "is not an integer". Something similar happens in Function.prototype.bind for targetLengthAsInt.
|
I see some additional uses of |
|
In |
|
All other uses of finite LGTM. |
bc07c90 to
eda5ab8
Compare
…ntial,toFixed,toPrecision}
eda5ab8 to
00bfbea
Compare
00bfbea to
5dbf2af
Compare
…ainder with other AOs
Agreed 😭 . Done.
Fixed. |
| 1. If _number_ is not a finite Number, return Number::toString(_number_, 10). | ||
| 1. If _fractionCount_ is not an integer, throw a *RangeError* exception. |
There was a problem hiding this comment.
These steps are being aligned across Number.protototype.{toExponential,toFixed,toPrecision}. The integer check is optional because relational operators support extended mathematical values, but these are cases where we tend to be explicit for minimizing cognitive burden. Further refactoring could combine both checks into a single step and/or use inclusive interval in the range check, and I'm deferring both of those options to the future as out of scope for a PR whose focus is introducing the term "finite Number".
| 1. If _numerator_ is either *+0*<sub>𝔽</sub> or *-0*<sub>𝔽</sub>, return _numerator_. | ||
| 1. Assert: _numerator_ and _denominator_ are finite and non-zero. | ||
| 1. Assert: _numerator_ is a finite Number and is neither *+0*<sub>𝔽</sub> nor *-0*<sub>𝔽</sub>. | ||
| 1. Assert: _denominator_ is a finite Number and is neither *+0*<sub>𝔽</sub> nor *-0*<sub>𝔽</sub>. |
There was a problem hiding this comment.
"is a finite Number and is neither +0𝔽 nor -0𝔽" is a very common check in Number-related algorithms; we should consider a shorter way to express it.
There was a problem hiding this comment.
I'd be okay defining nonzero finite Number.
There was a problem hiding this comment.
I guess it would be non-zero finite Number; we always include the hyphen.
| 1. If _x_ is an Object and _y_ is either a String, a Number, a BigInt, or a Symbol, return ! IsLooselyEqual(? ToPrimitive(_x_), _y_). | ||
| 1. If _x_ is a BigInt and _y_ is a Number, or if _x_ is a Number and _y_ is a BigInt, then | ||
| 1. If _x_ is not finite or _y_ is not finite, return *false*. | ||
| 1. If _x_ is a Number and _x_ is not a finite Number, return *false*. |
There was a problem hiding this comment.
So this is just NaN, +∞, and -∞, right? Would it be better to just say that?
|
We should give esmeta a heads up about this and see if they could add support for the new term before landing. |
Indeed: es-meta/esmeta#346 |
| 1. If _x_ is a BigInt and _y_ is a Number, or if _x_ is a Number and _y_ is a BigInt, then | ||
| 1. If _x_ is not finite or _y_ is not finite, return *false*. | ||
| 1. If _x_ is a Number and _x_ is not a finite Number, return *false*. | ||
| 1. If _y_ is a Number and _y_ is not a finite Number, return *false*. | ||
| 1. If ℝ(_x_) = ℝ(_y_), return *true*. | ||
| 1. Return *false*. | ||
| 1. Return *false*. |
There was a problem hiding this comment.
So this is just NaN, +∞, and -∞, right? Would it be better to just say that?
I'd rather not enumerate three exceptions. If we don't like this phrasing, my preference would instead be
| 1. If _x_ is a BigInt and _y_ is a Number, or if _x_ is a Number and _y_ is a BigInt, then | |
| 1. If _x_ is not finite or _y_ is not finite, return *false*. | |
| 1. If _x_ is a Number and _x_ is not a finite Number, return *false*. | |
| 1. If _y_ is a Number and _y_ is not a finite Number, return *false*. | |
| 1. If ℝ(_x_) = ℝ(_y_), return *true*. | |
| 1. Return *false*. | |
| 1. Return *false*. | |
| 1. If _x_ is a BigInt and _y_ is a finite Number, or if _x_ is a finite Number and _y_ is a BigInt, then | |
| 1. If ℝ(_x_) = ℝ(_y_), return *true*. | |
| 1. Return *false*. |
...taking advantage of type mismatch after the first step Ref tc39#3911 (comment)
...taking advantage of type mismatch after the first step Ref tc39#3911 (comment)
...fixing inappropriate auto-linking for uses of "finite" as a colloquial term
Fixes #3840
This does not affect Web IDL, HTML, or WebAssembly. ECMA-402 has a corresponding PR at tc39/ecma402#1091 , which can land independently of this one.