profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/NE-SmallTown/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.
Heaven NE-SmallTown 社交账号/微信已弃用,feel free to leave a message Nowhere, China Web Performance. Framework Digging. HTML & ECMA Spec. React. Love movie and music. I have to, .... yea, I know, but, I just, have to

NE-SmallTown/my-understanding-of-react 4

Add my understanding of React src code with comments

NE-SmallTown/hisomething 3

对国内互联网加班问题的一些调查材料(2020 - 2021)

NE-SmallTown/ant-design 0

🐜 A UI Design Language

NE-SmallTown/ant-design-jQuery 0

implement parts of ant-design by jQuery

NE-SmallTown/awesome-mobile-shits 0

Like https://github.com/RubyLouvre/mobileHack

NE-SmallTown/babel-plugin-react-css-modules 0

Transforms styleName to className using compile time CSS module resolution.

NE-SmallTown/build-your-own-mint 0

Build your own personal finance analytics using Plaid, Google Sheets and CircleCI.

NE-SmallTown/checkbox 0

React Checkbox

NE-SmallTown/component-compiler-utils 0

Lower level utilities for compiling Vue single file components

pull request commenttc39/ecma262

Replace each abstract op's preamble with a structured 'header'.

I've left the tags on successive lines (for ease of later insertion).

That's fine too.

jmdyck

comment created time in 30 minutes

push eventjsfront/month

jikeytang

commit sha c17f5a72f7091abcd2d536de3124cac089a72ceb

add

view details

jikeytang

commit sha f1ebbab08d388b263671607b5ba777c67d8afd28

Merge remote-tracking branch 'origin/master'

view details

push time in 4 hours

pull request commenttc39/ecma262

Replace each abstract op's preamble with a structured 'header'.

The last remaining change I'd like to see is to drop the returns and also has access to sections.

Done.

  • The returns sections as currently structured don't really make sense in a world where not all AOs return completion records,

I disagree: I do my static type analysis in such a world, so they make enough sense for that. But we can discuss that in 1796 or in chat.

  • SortCompare ... we could put the It also has access to the <var>comparefn</var> argument passed to the current invocation of the <code>sort</code> method. in the description without needing to support a new kind of header.

Done.

Plus there's some interest in removing these implicit parameters as well.

Yup, but not a lot of action.

This will leave many headers empty. I'm OK with that - they can be present as <dl class='header'></dl>, awaiting later use.

Do you specifically want them on one line like that? I've left the tags on successive lines (for ease of later insertion).

jmdyck

comment created time in 4 hours

starteddtinth/comic-mono-font

started time in 5 hours

release blitz-js/blitz

v0.38.1

released time in 7 hours

issue commentwhatwg/html

"Any other end tag"

I posted this response to your comments in the html5lib repo, but I'd meant to do it here:

See also whatwg/html#5113 and whatwg/html#6736

I believe your reading is correct - and that it was pointed out that this created a dangerous loophole for exploiting sanitizer round tripping. I'm not certain but I think maybe due to the nature of the problem vendors and some libraries may have addressed it before the spec was actually updated to reflect the necessary change.

The open PR addresses it by making </p> pop open elements until an HTML element / HTML integration point element is the current node.

stevecheckoway

comment created time in 7 hours

Pull request review commenttc39/ecma262

Editorial: extract StringNumericValue from MV and add/use RoundStringMVResult helper

 <h2>Syntax</h2>           </ul>         </emu-note> -        <emu-clause id="sec-runtime-semantics-mv-s">-          <h1>Runtime Semantics: MV</h1>-          <p>The conversion of a String to a Number value is similar overall to the determination of the Number value for a numeric literal (see <emu-xref href="#sec-literals-numeric-literals"></emu-xref>), but some of the details are different, so the process for converting a String numeric literal to a value of Number type is given here. This value is determined in two steps: first, a mathematical value (MV) is derived from the String numeric literal; second, this mathematical value is rounded as described below. The MV on any grammar symbol, not provided below, is the MV for that symbol defined in <emu-xref href="#sec-static-semantics-mv"></emu-xref>.</p>-          <ul>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: [empty]</emu-grammar> is 0.-            </li>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: StrWhiteSpace</emu-grammar> is 0.-            </li>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: StrWhiteSpace? StrNumericLiteral StrWhiteSpace?</emu-grammar> is the MV of |StrNumericLiteral|, no matter whether white space is present or not.-            </li>-            <li>-              The MV of <emu-grammar>StrDecimalLiteral ::: `-` StrUnsignedDecimalLiteral</emu-grammar> is the negative of the MV of |StrUnsignedDecimalLiteral|. (Note that if the MV of |StrUnsignedDecimalLiteral| is 0, the negative of this MV is also 0. The rounding rule described below handles the conversion of this signless mathematical zero to a floating-point *+0*<sub>𝔽</sub> or *-0*<sub>𝔽</sub> as appropriate.)-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `Infinity`</emu-grammar> is 10<sup>10000</sup> (a value so large that it will round to *+&infin;*<sub>𝔽</sub>).-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits</emu-grammar> is the MV of the first |DecimalDigits| plus (the MV of the second |DecimalDigits| times 10<sup>-_n_</sup>), where _n_ is the number of code points in the second |DecimalDigits|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_</sup>, where _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits ExponentPart</emu-grammar> is (the MV of the first |DecimalDigits| plus (the MV of the second |DecimalDigits| times 10<sup>-_n_</sup>)) times 10<sup>_e_</sup>, where _n_ is the number of code points in the second |DecimalDigits| and _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits</emu-grammar> is the MV of |DecimalDigits| times 10<sup>-_n_</sup>, where _n_ is the number of code points in |DecimalDigits|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_ - _n_</sup>, where _n_ is the number of code points in |DecimalDigits| and _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_</sup>, where _e_ is the MV of |ExponentPart|.-            </li>-          </ul>-          <p>Once the exact MV for a String numeric literal has been determined, it is then rounded to a value of the Number type. If the MV is 0, then the rounded value is *+0*<sub>𝔽</sub> unless the first non white space code point in the String numeric literal is `-`, in which case the rounded value is *-0*<sub>𝔽</sub>. Otherwise, the rounded value must be the Number value for the MV (in the sense defined in <emu-xref href="#sec-ecmascript-language-types-number-type"></emu-xref>), unless the literal includes a |StrUnsignedDecimalLiteral| and the literal has more than 20 significant digits, in which case the Number value may be either the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit or the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit and then incrementing the literal at the 20th digit position. A digit is significant if it is not part of an |ExponentPart| and</p>-          <ul>-            <li>-              it is not `0`; or-            </li>-            <li>-              there is a non-zero digit to its left and there is a non-zero digit, not in the |ExponentPart|, to its right.-            </li>-          </ul>+        <emu-clause id="sec-runtime-semantics-stringnumericvalue" aoid="StringNumericValue" oldids="sec-runtime-semantics-mv-s">+          <h1>Runtime Semantics: StringNumericValue</h1>+          <p>The conversion of a String to a Number value is similar overall to the determination of the Number value for a numeric literal (see <emu-xref href="#sec-literals-numeric-literals"></emu-xref>), but some of the details are different, so the process for converting a String numeric literal to a value of Number type is given here.</p>+          <emu-grammar>StringNumericLiteral ::: StrWhiteSpace?</emu-grammar>+          <emu-alg>+            1. Return *+0*<sub>𝔽</sub>.+          </emu-alg>+          <emu-grammar>StringNumericLiteral ::: StrWhiteSpace? StrNumericLiteral StrWhiteSpace?</emu-grammar>+          <emu-alg>+            1. Return StringNumericValue of |StrNumericLiteral|.+          </emu-alg>+          <emu-grammar>StrNumericLiteral ::: NonDecimalIntegerLiteral</emu-grammar>+          <emu-alg>+            1. Return RoundStringMVResult(MV of |NonDecimalIntegerLiteral|).+          </emu-alg>+          <emu-grammar>+            StrDecimalLiteral ::: StrUnsignedDecimalLiteral+            StrDecimalLiteral ::: `+` StrUnsignedDecimalLiteral+          </emu-grammar>+          <emu-alg>+            1. Return StringNumericValue of |StrUnsignedDecimalLiteral|.+          </emu-alg>+          <emu-grammar>StrDecimalLiteral ::: `-` StrUnsignedDecimalLiteral</emu-grammar>+          <emu-alg>+            1. Let _a_ be StringNumericValue of |StrUnsignedDecimalLiteral|.+            1. If _a_ is *+0*<sub>𝔽</sub>, return *-0*<sub>𝔽</sub>.+            1. Return -_a_.+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: `Infinity`</emu-grammar>+          <emu-alg>+            1. Return *+&infin;*<sub>𝔽</sub>.+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits? ExponentPart?</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of the first |DecimalDigits|.+            1. If the second |DecimalDigits| is present, let _b_ be MV of the second |DecimalDigits|. Otherwise, let _b_ be 0.+            1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0.+            1. Let _n_ be the number of code points in the second |DecimalDigits|.+            1. Return RoundStringMVResult((_a_ + (_b_ &times; 10<sup>-_n_</sup>)) &times; 10<sup>_e_</sup>).+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits ExponentPart?</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of |DecimalDigits|.+            1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0.+            1. Let _n_ be the number of code points in |DecimalDigits|.+            1. Return RoundStringMVResult(_a_ &times; 10<sup>_e_-_n_</sup>).+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPart?</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of |DecimalDigits|.+            1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0.+            1. Return RoundStringMVResult(_a_ &times; 10<sup>_e_</sup>).+          </emu-alg>+        </emu-clause>++        <emu-clause id="sec-roundstringmvresult" aoid="RoundStringMVResult">+          <h1>RoundStringMVResult ( _n_ )</h1>+          <p>The abstract operation RoundStringMVResult takes argument _n_ (a mathematical value). It converts _n_ to a Number in an implementation-defined manner. For the purposes of this abstract operation, a digit is significant if it is not zero or there is a non-zero digit to its left and there is a non-zero digit to its right. For the purposes of this abstract operation, "the mathematical value denoted by" a representation of a mathematical value is the inverse of "the decimal representation of" a mathematical value. It performs the following steps when called:</p>+          <emu-alg>+            1. If the decimal representation of _n_ has fewer than 20 significant digits, return 𝔽(_n_).

Oh, something else: In the current spec, "the decimal representation of x" is only applied to integers (and only positive integers, I think), whereas this applies it to non-integers (and negatives, and zero). I don't think this creates any definitional problems, but I thought it shouldn't go un-noted.

michaelficarra

comment created time in 8 hours

Pull request review commenttc39/ecma262

Editorial: extract StringNumericValue from MV and add/use RoundStringMVResult helper

 <h2>Syntax</h2>          <emu-clause id="sec-runtime-semantics-mv-s">           <h1>Runtime Semantics: MV</h1>-          <p>The conversion of a String to a Number value is similar overall to the determination of the Number value for a numeric literal (see <emu-xref href="#sec-literals-numeric-literals"></emu-xref>), but some of the details are different, so the process for converting a String numeric literal to a value of Number type is given here. This value is determined in two steps: first, a mathematical value (MV) is derived from the String numeric literal; second, this mathematical value is rounded as described below. The MV on any grammar symbol, not provided below, is the MV for that symbol defined in <emu-xref href="#sec-static-semantics-mv"></emu-xref>.</p>-          <ul>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: [empty]</emu-grammar> is 0.-            </li>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: StrWhiteSpace</emu-grammar> is 0.-            </li>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: StrWhiteSpace? StrNumericLiteral StrWhiteSpace?</emu-grammar> is the MV of |StrNumericLiteral|, no matter whether white space is present or not.-            </li>-            <li>-              The MV of <emu-grammar>StrDecimalLiteral ::: `-` StrUnsignedDecimalLiteral</emu-grammar> is the negative of the MV of |StrUnsignedDecimalLiteral|. (Note that if the MV of |StrUnsignedDecimalLiteral| is 0, the negative of this MV is also 0. The rounding rule described below handles the conversion of this signless mathematical zero to a floating-point *+0*<sub>𝔽</sub> or *-0*<sub>𝔽</sub> as appropriate.)-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `Infinity`</emu-grammar> is 10<sup>10000</sup> (a value so large that it will round to *+&infin;*<sub>𝔽</sub>).-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits</emu-grammar> is the MV of the first |DecimalDigits| plus (the MV of the second |DecimalDigits| times 10<sup>-_n_</sup>), where _n_ is the number of code points in the second |DecimalDigits|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_</sup>, where _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits ExponentPart</emu-grammar> is (the MV of the first |DecimalDigits| plus (the MV of the second |DecimalDigits| times 10<sup>-_n_</sup>)) times 10<sup>_e_</sup>, where _n_ is the number of code points in the second |DecimalDigits| and _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits</emu-grammar> is the MV of |DecimalDigits| times 10<sup>-_n_</sup>, where _n_ is the number of code points in |DecimalDigits|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_ - _n_</sup>, where _n_ is the number of code points in |DecimalDigits| and _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_</sup>, where _e_ is the MV of |ExponentPart|.-            </li>-          </ul>-          <p>Once the exact MV for a String numeric literal has been determined, it is then rounded to a value of the Number type. If the MV is 0, then the rounded value is *+0*<sub>𝔽</sub> unless the first non white space code point in the String numeric literal is `-`, in which case the rounded value is *-0*<sub>𝔽</sub>. Otherwise, the rounded value must be the Number value for the MV (in the sense defined in <emu-xref href="#sec-ecmascript-language-types-number-type"></emu-xref>), unless the literal includes a |StrUnsignedDecimalLiteral| and the literal has more than 20 significant digits, in which case the Number value may be either the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit or the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit and then incrementing the literal at the 20th digit position. A digit is significant if it is not part of an |ExponentPart| and</p>-          <ul>-            <li>-              it is not `0`; or-            </li>-            <li>-              there is a non-zero digit to its left and there is a non-zero digit, not in the |ExponentPart|, to its right.-            </li>-          </ul>+          <p>The conversion of a String to a Number value is similar overall to the determination of the Number value for a numeric literal (see <emu-xref href="#sec-literals-numeric-literals"></emu-xref>), but some of the details are different, so the process for converting a String numeric literal to a value of Number type is given here. Additional definitions for MV are provided in <emu-xref href="#sec-static-semantics-mv"></emu-xref>.</p>+          <emu-grammar>StringNumericLiteral ::: [empty]</emu-grammar>+          <emu-grammar>StringNumericLiteral ::: StrWhiteSpace</emu-grammar>+          <emu-alg>+            1. Return *+0*<sub>𝔽</sub>.+          </emu-alg>+          <emu-grammar>StringNumericLiteral ::: StrWhiteSpace? StrNumericLiteral StrWhiteSpace?</emu-grammar>+          <emu-alg>+            1. Return 𝔽(MV of |StrNumericLiteral|).+          </emu-alg>+          <emu-grammar>StrDecimalLiteral ::: `-` StrUnsignedDecimalLiteral</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of |StrUnsignedDecimalLiteral|.+            1. If _a_ is 0, return *-0*<sub>𝔽</sub>.+            1. Return RoundStringMVResult(-1 &times; _a_).+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: `Infinity`</emu-grammar>+          <emu-alg>+            1. Return *+&infin;*<sub>𝔽</sub>.+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits? ExponentPart?</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of the first |DecimalDigits|.+            1. If the second |DecimalDigits| is present, let _b_ be MV of the second |DecimalDigits|. Otherwise, let _b_ be 0.+            1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0.+            1. Let _n_ be the number of code points in the second |DecimalDigits|.+            1. Return RoundStringMVResult((_a_ + (_b_ &times; 10<sup>-_n_</sup>)) &times; 10<sup>_e_</sup>).+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits ExponentPart?</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of |DecimalDigits|.+            1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0.+            1. Let _n_ be the number of code points in |DecimalDigits|.+            1. Return RoundStringMVResult(_a_ &times; 10<sup>_e_-_n_</sup>).+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPart?</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of |DecimalDigits|.+            1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0.+            1. Return RoundStringMVResult(_a_ &times; 10<sup>_e_</sup>).+          </emu-alg>+        </emu-clause>++        <emu-clause id="sec-roundstringmvresult" aoid="RoundStringMVResult">+          <h1>RoundStringMVResult ( _n_ )</h1>+          <p>The abstract operation RoundStringMVResult takes argument _n_ (a mathematical value). It converts _n_ to a Number in an implementation-defined manner. For the purposes of this abstract operation, a digit is significant if it is not zero or there is a non-zero digit to its left and there is a non-zero digit to its right. It performs the following steps when called:</p>+          <emu-alg>+            1. If the decimal representation of _n_ has fewer than 20 significant digits in its decimal representation, return 𝔽(_n_).+            1. Let _option1_ be the mathematical value denoted by the result of replacing each significant digit in the decimal representation of _n_ after the 20th with a 0 digit.+            1. Let _option2_ be the mathematical value denoted by the result of replacing each significant digit in the decimal representation of _n_ after the 20th with a 0 digit and then incrementing it at the 20th position (with carrying as necessary).

Okay, thanks.

michaelficarra

comment created time in 8 hours

startedelwayman02/ember-scroll-modifiers

started time in 8 hours

startedNullVoxPopuli/ember-deep-tracked

started time in 8 hours

Pull request review commenttc39/ecma262

Editorial: extract StringNumericValue from MV and add/use RoundStringMVResult helper

 <h2>Syntax</h2>          <emu-clause id="sec-runtime-semantics-mv-s">           <h1>Runtime Semantics: MV</h1>-          <p>The conversion of a String to a Number value is similar overall to the determination of the Number value for a numeric literal (see <emu-xref href="#sec-literals-numeric-literals"></emu-xref>), but some of the details are different, so the process for converting a String numeric literal to a value of Number type is given here. This value is determined in two steps: first, a mathematical value (MV) is derived from the String numeric literal; second, this mathematical value is rounded as described below. The MV on any grammar symbol, not provided below, is the MV for that symbol defined in <emu-xref href="#sec-static-semantics-mv"></emu-xref>.</p>-          <ul>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: [empty]</emu-grammar> is 0.-            </li>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: StrWhiteSpace</emu-grammar> is 0.-            </li>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: StrWhiteSpace? StrNumericLiteral StrWhiteSpace?</emu-grammar> is the MV of |StrNumericLiteral|, no matter whether white space is present or not.-            </li>-            <li>-              The MV of <emu-grammar>StrDecimalLiteral ::: `-` StrUnsignedDecimalLiteral</emu-grammar> is the negative of the MV of |StrUnsignedDecimalLiteral|. (Note that if the MV of |StrUnsignedDecimalLiteral| is 0, the negative of this MV is also 0. The rounding rule described below handles the conversion of this signless mathematical zero to a floating-point *+0*<sub>𝔽</sub> or *-0*<sub>𝔽</sub> as appropriate.)-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `Infinity`</emu-grammar> is 10<sup>10000</sup> (a value so large that it will round to *+&infin;*<sub>𝔽</sub>).-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits</emu-grammar> is the MV of the first |DecimalDigits| plus (the MV of the second |DecimalDigits| times 10<sup>-_n_</sup>), where _n_ is the number of code points in the second |DecimalDigits|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_</sup>, where _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits ExponentPart</emu-grammar> is (the MV of the first |DecimalDigits| plus (the MV of the second |DecimalDigits| times 10<sup>-_n_</sup>)) times 10<sup>_e_</sup>, where _n_ is the number of code points in the second |DecimalDigits| and _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits</emu-grammar> is the MV of |DecimalDigits| times 10<sup>-_n_</sup>, where _n_ is the number of code points in |DecimalDigits|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_ - _n_</sup>, where _n_ is the number of code points in |DecimalDigits| and _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_</sup>, where _e_ is the MV of |ExponentPart|.-            </li>-          </ul>-          <p>Once the exact MV for a String numeric literal has been determined, it is then rounded to a value of the Number type. If the MV is 0, then the rounded value is *+0*<sub>𝔽</sub> unless the first non white space code point in the String numeric literal is `-`, in which case the rounded value is *-0*<sub>𝔽</sub>. Otherwise, the rounded value must be the Number value for the MV (in the sense defined in <emu-xref href="#sec-ecmascript-language-types-number-type"></emu-xref>), unless the literal includes a |StrUnsignedDecimalLiteral| and the literal has more than 20 significant digits, in which case the Number value may be either the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit or the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit and then incrementing the literal at the 20th digit position. A digit is significant if it is not part of an |ExponentPart| and</p>-          <ul>-            <li>-              it is not `0`; or-            </li>-            <li>-              there is a non-zero digit to its left and there is a non-zero digit, not in the |ExponentPart|, to its right.-            </li>-          </ul>+          <p>The conversion of a String to a Number value is similar overall to the determination of the Number value for a numeric literal (see <emu-xref href="#sec-literals-numeric-literals"></emu-xref>), but some of the details are different, so the process for converting a String numeric literal to a value of Number type is given here. Additional definitions for MV are provided in <emu-xref href="#sec-static-semantics-mv"></emu-xref>.</p>+          <emu-grammar>StringNumericLiteral ::: [empty]</emu-grammar>+          <emu-grammar>StringNumericLiteral ::: StrWhiteSpace</emu-grammar>+          <emu-alg>+            1. Return *+0*<sub>𝔽</sub>.+          </emu-alg>+          <emu-grammar>StringNumericLiteral ::: StrWhiteSpace? StrNumericLiteral StrWhiteSpace?</emu-grammar>+          <emu-alg>+            1. Return 𝔽(MV of |StrNumericLiteral|).+          </emu-alg>+          <emu-grammar>StrDecimalLiteral ::: `-` StrUnsignedDecimalLiteral</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of |StrUnsignedDecimalLiteral|.+            1. If _a_ is 0, return *-0*<sub>𝔽</sub>.+            1. Return RoundStringMVResult(-1 &times; _a_).+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: `Infinity`</emu-grammar>+          <emu-alg>+            1. Return *+&infin;*<sub>𝔽</sub>.+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits? ExponentPart?</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of the first |DecimalDigits|.+            1. If the second |DecimalDigits| is present, let _b_ be MV of the second |DecimalDigits|. Otherwise, let _b_ be 0.+            1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0.+            1. Let _n_ be the number of code points in the second |DecimalDigits|.+            1. Return RoundStringMVResult((_a_ + (_b_ &times; 10<sup>-_n_</sup>)) &times; 10<sup>_e_</sup>).+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits ExponentPart?</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of |DecimalDigits|.+            1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0.+            1. Let _n_ be the number of code points in |DecimalDigits|.+            1. Return RoundStringMVResult(_a_ &times; 10<sup>_e_-_n_</sup>).+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPart?</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of |DecimalDigits|.+            1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0.+            1. Return RoundStringMVResult(_a_ &times; 10<sup>_e_</sup>).+          </emu-alg>+        </emu-clause>++        <emu-clause id="sec-roundstringmvresult" aoid="RoundStringMVResult">+          <h1>RoundStringMVResult ( _n_ )</h1>+          <p>The abstract operation RoundStringMVResult takes argument _n_ (a mathematical value). It converts _n_ to a Number in an implementation-defined manner. For the purposes of this abstract operation, a digit is significant if it is not zero or there is a non-zero digit to its left and there is a non-zero digit to its right. It performs the following steps when called:</p>+          <emu-alg>+            1. If the decimal representation of _n_ has fewer than 20 significant digits in its decimal representation, return 𝔽(_n_).+            1. Let _option1_ be the mathematical value denoted by the result of replacing each significant digit in the decimal representation of _n_ after the 20th with a 0 digit.+            1. Let _option2_ be the mathematical value denoted by the result of replacing each significant digit in the decimal representation of _n_ after the 20th with a 0 digit and then incrementing it at the 20th position (with carrying as necessary).

I think it's reasonable to assume that readers understand how to derive a mathematical value from its decimal representation, as is done in this PR, but since MV (the "elsewhere") is working with parse nodes - which are not normally imbued with mathematical values as a matter of background knowledge, unlike decimal representations - it warrants a more explicit definition there. (Besides which, MV has a number of other cases it needs to define explicitly anyway, so it might as well be explicit in this case.)

That is to say: the operation "take the mathematical value denoted by this decimal representation" is a reasonable thing to assume readers are familiar with. The operation "take the mathematical value denoted by this parse node" is less so, even when the parse node happens to represent a string which is the decimal representation of a number, since the parse nodes are an artifact defined by this specification.

So I don't really regard this as an inconsistency. At any rate, I'm fine with it.

michaelficarra

comment created time in 9 hours

pull request commenttc39/ecma262

Editorial: extract StringNumericValue from MV and add/use RoundStringMVResult helper

(Hm, that's weird. I meant to submit a reply and a review separately, but GitHub seems to have merged them. I think it still makes sense.)

michaelficarra

comment created time in 9 hours

Pull request review commenttc39/ecma262

Editorial: extract StringNumericValue from MV and add/use RoundStringMVResult helper

 <h2>Syntax</h2>          <emu-clause id="sec-runtime-semantics-mv-s">           <h1>Runtime Semantics: MV</h1>-          <p>The conversion of a String to a Number value is similar overall to the determination of the Number value for a numeric literal (see <emu-xref href="#sec-literals-numeric-literals"></emu-xref>), but some of the details are different, so the process for converting a String numeric literal to a value of Number type is given here. This value is determined in two steps: first, a mathematical value (MV) is derived from the String numeric literal; second, this mathematical value is rounded as described below. The MV on any grammar symbol, not provided below, is the MV for that symbol defined in <emu-xref href="#sec-static-semantics-mv"></emu-xref>.</p>-          <ul>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: [empty]</emu-grammar> is 0.-            </li>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: StrWhiteSpace</emu-grammar> is 0.-            </li>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: StrWhiteSpace? StrNumericLiteral StrWhiteSpace?</emu-grammar> is the MV of |StrNumericLiteral|, no matter whether white space is present or not.-            </li>-            <li>-              The MV of <emu-grammar>StrDecimalLiteral ::: `-` StrUnsignedDecimalLiteral</emu-grammar> is the negative of the MV of |StrUnsignedDecimalLiteral|. (Note that if the MV of |StrUnsignedDecimalLiteral| is 0, the negative of this MV is also 0. The rounding rule described below handles the conversion of this signless mathematical zero to a floating-point *+0*<sub>𝔽</sub> or *-0*<sub>𝔽</sub> as appropriate.)-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `Infinity`</emu-grammar> is 10<sup>10000</sup> (a value so large that it will round to *+&infin;*<sub>𝔽</sub>).-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits</emu-grammar> is the MV of the first |DecimalDigits| plus (the MV of the second |DecimalDigits| times 10<sup>-_n_</sup>), where _n_ is the number of code points in the second |DecimalDigits|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_</sup>, where _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits ExponentPart</emu-grammar> is (the MV of the first |DecimalDigits| plus (the MV of the second |DecimalDigits| times 10<sup>-_n_</sup>)) times 10<sup>_e_</sup>, where _n_ is the number of code points in the second |DecimalDigits| and _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits</emu-grammar> is the MV of |DecimalDigits| times 10<sup>-_n_</sup>, where _n_ is the number of code points in |DecimalDigits|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_ - _n_</sup>, where _n_ is the number of code points in |DecimalDigits| and _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_</sup>, where _e_ is the MV of |ExponentPart|.-            </li>-          </ul>-          <p>Once the exact MV for a String numeric literal has been determined, it is then rounded to a value of the Number type. If the MV is 0, then the rounded value is *+0*<sub>𝔽</sub> unless the first non white space code point in the String numeric literal is `-`, in which case the rounded value is *-0*<sub>𝔽</sub>. Otherwise, the rounded value must be the Number value for the MV (in the sense defined in <emu-xref href="#sec-ecmascript-language-types-number-type"></emu-xref>), unless the literal includes a |StrUnsignedDecimalLiteral| and the literal has more than 20 significant digits, in which case the Number value may be either the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit or the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit and then incrementing the literal at the 20th digit position. A digit is significant if it is not part of an |ExponentPart| and</p>-          <ul>-            <li>-              it is not `0`; or-            </li>-            <li>-              there is a non-zero digit to its left and there is a non-zero digit, not in the |ExponentPart|, to its right.-            </li>-          </ul>+          <p>The conversion of a String to a Number value is similar overall to the determination of the Number value for a numeric literal (see <emu-xref href="#sec-literals-numeric-literals"></emu-xref>), but some of the details are different, so the process for converting a String numeric literal to a value of Number type is given here. Additional definitions for MV are provided in <emu-xref href="#sec-static-semantics-mv"></emu-xref>.</p>+          <emu-grammar>StringNumericLiteral ::: [empty]</emu-grammar>+          <emu-grammar>StringNumericLiteral ::: StrWhiteSpace</emu-grammar>+          <emu-alg>+            1. Return *+0*<sub>𝔽</sub>.+          </emu-alg>+          <emu-grammar>StringNumericLiteral ::: StrWhiteSpace? StrNumericLiteral StrWhiteSpace?</emu-grammar>+          <emu-alg>+            1. Return 𝔽(MV of |StrNumericLiteral|).+          </emu-alg>+          <emu-grammar>StrDecimalLiteral ::: `-` StrUnsignedDecimalLiteral</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of |StrUnsignedDecimalLiteral|.+            1. If _a_ is 0, return *-0*<sub>𝔽</sub>.+            1. Return RoundStringMVResult(-1 &times; _a_).+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: `Infinity`</emu-grammar>+          <emu-alg>+            1. Return *+&infin;*<sub>𝔽</sub>.+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits? ExponentPart?</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of the first |DecimalDigits|.+            1. If the second |DecimalDigits| is present, let _b_ be MV of the second |DecimalDigits|. Otherwise, let _b_ be 0.+            1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0.+            1. Let _n_ be the number of code points in the second |DecimalDigits|.+            1. Return RoundStringMVResult((_a_ + (_b_ &times; 10<sup>-_n_</sup>)) &times; 10<sup>_e_</sup>).+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits ExponentPart?</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of |DecimalDigits|.+            1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0.+            1. Let _n_ be the number of code points in |DecimalDigits|.+            1. Return RoundStringMVResult(_a_ &times; 10<sup>_e_-_n_</sup>).

If the editors prefer the superscript without spaces, there are about 18 other superscripts with spaces that you might wish to convert.

michaelficarra

comment created time in 9 hours

Pull request review commenttc39/ecma262

Editorial: extract StringNumericValue from MV and add/use RoundStringMVResult helper

 <h2>Syntax</h2>          <emu-clause id="sec-runtime-semantics-mv-s">           <h1>Runtime Semantics: MV</h1>-          <p>The conversion of a String to a Number value is similar overall to the determination of the Number value for a numeric literal (see <emu-xref href="#sec-literals-numeric-literals"></emu-xref>), but some of the details are different, so the process for converting a String numeric literal to a value of Number type is given here. This value is determined in two steps: first, a mathematical value (MV) is derived from the String numeric literal; second, this mathematical value is rounded as described below. The MV on any grammar symbol, not provided below, is the MV for that symbol defined in <emu-xref href="#sec-static-semantics-mv"></emu-xref>.</p>-          <ul>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: [empty]</emu-grammar> is 0.-            </li>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: StrWhiteSpace</emu-grammar> is 0.-            </li>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: StrWhiteSpace? StrNumericLiteral StrWhiteSpace?</emu-grammar> is the MV of |StrNumericLiteral|, no matter whether white space is present or not.-            </li>-            <li>-              The MV of <emu-grammar>StrDecimalLiteral ::: `-` StrUnsignedDecimalLiteral</emu-grammar> is the negative of the MV of |StrUnsignedDecimalLiteral|. (Note that if the MV of |StrUnsignedDecimalLiteral| is 0, the negative of this MV is also 0. The rounding rule described below handles the conversion of this signless mathematical zero to a floating-point *+0*<sub>𝔽</sub> or *-0*<sub>𝔽</sub> as appropriate.)-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `Infinity`</emu-grammar> is 10<sup>10000</sup> (a value so large that it will round to *+&infin;*<sub>𝔽</sub>).-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits</emu-grammar> is the MV of the first |DecimalDigits| plus (the MV of the second |DecimalDigits| times 10<sup>-_n_</sup>), where _n_ is the number of code points in the second |DecimalDigits|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_</sup>, where _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits ExponentPart</emu-grammar> is (the MV of the first |DecimalDigits| plus (the MV of the second |DecimalDigits| times 10<sup>-_n_</sup>)) times 10<sup>_e_</sup>, where _n_ is the number of code points in the second |DecimalDigits| and _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits</emu-grammar> is the MV of |DecimalDigits| times 10<sup>-_n_</sup>, where _n_ is the number of code points in |DecimalDigits|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_ - _n_</sup>, where _n_ is the number of code points in |DecimalDigits| and _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_</sup>, where _e_ is the MV of |ExponentPart|.-            </li>-          </ul>-          <p>Once the exact MV for a String numeric literal has been determined, it is then rounded to a value of the Number type. If the MV is 0, then the rounded value is *+0*<sub>𝔽</sub> unless the first non white space code point in the String numeric literal is `-`, in which case the rounded value is *-0*<sub>𝔽</sub>. Otherwise, the rounded value must be the Number value for the MV (in the sense defined in <emu-xref href="#sec-ecmascript-language-types-number-type"></emu-xref>), unless the literal includes a |StrUnsignedDecimalLiteral| and the literal has more than 20 significant digits, in which case the Number value may be either the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit or the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit and then incrementing the literal at the 20th digit position. A digit is significant if it is not part of an |ExponentPart| and</p>-          <ul>-            <li>-              it is not `0`; or-            </li>-            <li>-              there is a non-zero digit to its left and there is a non-zero digit, not in the |ExponentPart|, to its right.-            </li>-          </ul>+          <p>The conversion of a String to a Number value is similar overall to the determination of the Number value for a numeric literal (see <emu-xref href="#sec-literals-numeric-literals"></emu-xref>), but some of the details are different, so the process for converting a String numeric literal to a value of Number type is given here. Additional definitions for MV are provided in <emu-xref href="#sec-static-semantics-mv"></emu-xref>.</p>+          <emu-grammar>StringNumericLiteral ::: [empty]</emu-grammar>+          <emu-grammar>StringNumericLiteral ::: StrWhiteSpace</emu-grammar>+          <emu-alg>+            1. Return *+0*<sub>𝔽</sub>.+          </emu-alg>+          <emu-grammar>StringNumericLiteral ::: StrWhiteSpace? StrNumericLiteral StrWhiteSpace?</emu-grammar>+          <emu-alg>+            1. Return 𝔽(MV of |StrNumericLiteral|).+          </emu-alg>+          <emu-grammar>StrDecimalLiteral ::: `-` StrUnsignedDecimalLiteral</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of |StrUnsignedDecimalLiteral|.+            1. If _a_ is 0, return *-0*<sub>𝔽</sub>.+            1. Return RoundStringMVResult(-1 &times; _a_).+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: `Infinity`</emu-grammar>+          <emu-alg>+            1. Return *+&infin;*<sub>𝔽</sub>.+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits? ExponentPart?</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of the first |DecimalDigits|.+            1. If the second |DecimalDigits| is present, let _b_ be MV of the second |DecimalDigits|. Otherwise, let _b_ be 0.+            1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0.+            1. Let _n_ be the number of code points in the second |DecimalDigits|.+            1. Return RoundStringMVResult((_a_ + (_b_ &times; 10<sup>-_n_</sup>)) &times; 10<sup>_e_</sup>).+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits ExponentPart?</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of |DecimalDigits|.+            1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0.+            1. Let _n_ be the number of code points in |DecimalDigits|.+            1. Return RoundStringMVResult(_a_ &times; 10<sup>_e_-_n_</sup>).+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPart?</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of |DecimalDigits|.+            1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0.+            1. Return RoundStringMVResult(_a_ &times; 10<sup>_e_</sup>).+          </emu-alg>+        </emu-clause>++        <emu-clause id="sec-roundstringmvresult" aoid="RoundStringMVResult">+          <h1>RoundStringMVResult ( _n_ )</h1>+          <p>The abstract operation RoundStringMVResult takes argument _n_ (a mathematical value). It converts _n_ to a Number in an implementation-defined manner. For the purposes of this abstract operation, a digit is significant if it is not zero or there is a non-zero digit to its left and there is a non-zero digit to its right. It performs the following steps when called:</p>+          <emu-alg>+            1. If the decimal representation of _n_ has fewer than 20 significant digits in its decimal representation, return 𝔽(_n_).+            1. Let _option1_ be the mathematical value denoted by the result of replacing each significant digit in the decimal representation of _n_ after the 20th with a 0 digit.+            1. Let _option2_ be the mathematical value denoted by the result of replacing each significant digit in the decimal representation of _n_ after the 20th with a 0 digit and then incrementing it at the 20th position (with carrying as necessary).

Is the fact that the name MV is composed of the first two letters of "mathematical" and "value" causing you to think that it is being used as an initialism for "mathematical value" instead of to refer to the AO with that name?

Nope.

Do you agree with me that the AO named MV and the prose "the mathematical value of" are not related in any way?

Sure:

  • MV is an AO that maps literals to mathematical values.
  • "the mathematical value of" is a special phrase that 'converts' Numbers and BigInts to mathematical values.

And neither is defined in terms of the other.

However, what I'm talking about here is the new phrase "the mathematical value denoted by", which maps 'representations' to mathematical values, and thus is similar to (some of) what MV currently does. I'm saying it's odd that RoundStringMVResult can just say "the mathematical value denoted by x" when elsewhere we explicitly do the arithmetic to accomplish the same result. It's an inconsistency in what the spec assumes as its 'base level'.

We talked about this a bit in the editor call today. @jmdyck does the most recent commit address your concerns?

(This adds a sentence to RoundStringMVResult defining the new phrase.) That's an improvement, I guess, but no, I don't think it addresses the point I raised.

  • One way to address it would be, as in the current spec, to use MV (rather than the new phrase) to get the mathematical values of the two 20-digit options. (Though that's somewhat complicated by RoundStringMVResult working with decimal representations rather than literals.)

  • Another way would be to keep the new phrase and use it elsewhere instead of explicit arithmetic. (Though I don't know how well that would work out.)

But if the editors understand my point and are okay with the inconsistency, well, it's not like it'd be the only one in the spec.

michaelficarra

comment created time in 9 hours

Pull request review commenttc39/ecma262

Editorial: extract StringNumericValue from MV and add/use RoundStringMVResult helper

 <h2>Syntax</h2>           </ul>         </emu-note> -        <emu-clause id="sec-runtime-semantics-mv-s">-          <h1>Runtime Semantics: MV</h1>-          <p>The conversion of a String to a Number value is similar overall to the determination of the Number value for a numeric literal (see <emu-xref href="#sec-literals-numeric-literals"></emu-xref>), but some of the details are different, so the process for converting a String numeric literal to a value of Number type is given here. This value is determined in two steps: first, a mathematical value (MV) is derived from the String numeric literal; second, this mathematical value is rounded as described below. The MV on any grammar symbol, not provided below, is the MV for that symbol defined in <emu-xref href="#sec-static-semantics-mv"></emu-xref>.</p>-          <ul>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: [empty]</emu-grammar> is 0.-            </li>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: StrWhiteSpace</emu-grammar> is 0.-            </li>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: StrWhiteSpace? StrNumericLiteral StrWhiteSpace?</emu-grammar> is the MV of |StrNumericLiteral|, no matter whether white space is present or not.-            </li>-            <li>-              The MV of <emu-grammar>StrDecimalLiteral ::: `-` StrUnsignedDecimalLiteral</emu-grammar> is the negative of the MV of |StrUnsignedDecimalLiteral|. (Note that if the MV of |StrUnsignedDecimalLiteral| is 0, the negative of this MV is also 0. The rounding rule described below handles the conversion of this signless mathematical zero to a floating-point *+0*<sub>𝔽</sub> or *-0*<sub>𝔽</sub> as appropriate.)-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `Infinity`</emu-grammar> is 10<sup>10000</sup> (a value so large that it will round to *+&infin;*<sub>𝔽</sub>).-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits</emu-grammar> is the MV of the first |DecimalDigits| plus (the MV of the second |DecimalDigits| times 10<sup>-_n_</sup>), where _n_ is the number of code points in the second |DecimalDigits|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_</sup>, where _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits ExponentPart</emu-grammar> is (the MV of the first |DecimalDigits| plus (the MV of the second |DecimalDigits| times 10<sup>-_n_</sup>)) times 10<sup>_e_</sup>, where _n_ is the number of code points in the second |DecimalDigits| and _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits</emu-grammar> is the MV of |DecimalDigits| times 10<sup>-_n_</sup>, where _n_ is the number of code points in |DecimalDigits|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_ - _n_</sup>, where _n_ is the number of code points in |DecimalDigits| and _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_</sup>, where _e_ is the MV of |ExponentPart|.-            </li>-          </ul>-          <p>Once the exact MV for a String numeric literal has been determined, it is then rounded to a value of the Number type. If the MV is 0, then the rounded value is *+0*<sub>𝔽</sub> unless the first non white space code point in the String numeric literal is `-`, in which case the rounded value is *-0*<sub>𝔽</sub>. Otherwise, the rounded value must be the Number value for the MV (in the sense defined in <emu-xref href="#sec-ecmascript-language-types-number-type"></emu-xref>), unless the literal includes a |StrUnsignedDecimalLiteral| and the literal has more than 20 significant digits, in which case the Number value may be either the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit or the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit and then incrementing the literal at the 20th digit position. A digit is significant if it is not part of an |ExponentPart| and</p>-          <ul>-            <li>-              it is not `0`; or-            </li>-            <li>-              there is a non-zero digit to its left and there is a non-zero digit, not in the |ExponentPart|, to its right.-            </li>-          </ul>+        <emu-clause id="sec-runtime-semantics-stringnumericvalue" aoid="StringNumericValue" oldids="sec-runtime-semantics-mv-s">+          <h1>Runtime Semantics: StringNumericValue</h1>+          <p>The conversion of a String to a Number value is similar overall to the determination of the Number value for a numeric literal (see <emu-xref href="#sec-literals-numeric-literals"></emu-xref>), but some of the details are different, so the process for converting a String numeric literal to a value of Number type is given here.</p>+          <emu-grammar>StringNumericLiteral ::: StrWhiteSpace?</emu-grammar>+          <emu-alg>+            1. Return *+0*<sub>𝔽</sub>.+          </emu-alg>+          <emu-grammar>StringNumericLiteral ::: StrWhiteSpace? StrNumericLiteral StrWhiteSpace?</emu-grammar>+          <emu-alg>+            1. Return StringNumericValue of |StrNumericLiteral|.+          </emu-alg>+          <emu-grammar>StrNumericLiteral ::: NonDecimalIntegerLiteral</emu-grammar>+          <emu-alg>+            1. Return RoundStringMVResult(MV of |NonDecimalIntegerLiteral|).+          </emu-alg>+          <emu-grammar>+            StrDecimalLiteral ::: StrUnsignedDecimalLiteral+            StrDecimalLiteral ::: `+` StrUnsignedDecimalLiteral+          </emu-grammar>+          <emu-alg>+            1. Return StringNumericValue of |StrUnsignedDecimalLiteral|.+          </emu-alg>+          <emu-grammar>StrDecimalLiteral ::: `-` StrUnsignedDecimalLiteral</emu-grammar>+          <emu-alg>+            1. Let _a_ be StringNumericValue of |StrUnsignedDecimalLiteral|.+            1. If _a_ is *+0*<sub>𝔽</sub>, return *-0*<sub>𝔽</sub>.+            1. Return -_a_.+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: `Infinity`</emu-grammar>+          <emu-alg>+            1. Return *+&infin;*<sub>𝔽</sub>.+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits? ExponentPart?</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of the first |DecimalDigits|.+            1. If the second |DecimalDigits| is present, let _b_ be MV of the second |DecimalDigits|. Otherwise, let _b_ be 0.+            1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0.+            1. Let _n_ be the number of code points in the second |DecimalDigits|.+            1. Return RoundStringMVResult((_a_ + (_b_ &times; 10<sup>-_n_</sup>)) &times; 10<sup>_e_</sup>).+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits ExponentPart?</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of |DecimalDigits|.+            1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0.+            1. Let _n_ be the number of code points in |DecimalDigits|.+            1. Return RoundStringMVResult(_a_ &times; 10<sup>_e_-_n_</sup>).+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPart?</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of |DecimalDigits|.+            1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0.+            1. Return RoundStringMVResult(_a_ &times; 10<sup>_e_</sup>).+          </emu-alg>+        </emu-clause>++        <emu-clause id="sec-roundstringmvresult" aoid="RoundStringMVResult">+          <h1>RoundStringMVResult ( _n_ )</h1>+          <p>The abstract operation RoundStringMVResult takes argument _n_ (a mathematical value). It converts _n_ to a Number in an implementation-defined manner. For the purposes of this abstract operation, a digit is significant if it is not zero or there is a non-zero digit to its left and there is a non-zero digit to its right. For the purposes of this abstract operation, "the mathematical value denoted by" a representation of a mathematical value is the inverse of "the decimal representation of" a mathematical value. It performs the following steps when called:</p>+          <emu-alg>+            1. If the decimal representation of _n_ has fewer than 20 significant digits, return 𝔽(_n_).+            1. Let _option1_ be the mathematical value denoted by the result of replacing each significant digit in the decimal representation of _n_ after the 20th with a 0 digit.+            1. Let _option2_ be the mathematical value denoted by the result of replacing each significant digit in the decimal representation of _n_ after the 20th with a 0 digit and then incrementing it at the 20th position (with carrying as necessary).+            1. Let _chosen_ be an implementation-defined choice of either _option1_ or _option2_.+            1. Return 𝔽(_chosen_).+          </emu-alg>

Before the call to RoundStringMVResult, we convert a decimal representation to a mathematical value, and then inside the call, we convert that to a decimal representation, tweak that, then convert that to a mathematical value, and convert that to a Number. So it's:

  • decimal rep -> math value -> decimal rep -> math value -> Number

I'm not saying it's wrong, it just seems circuitous.

michaelficarra

comment created time in 9 hours

Pull request review commenttc39/ecma262

Editorial: extract StringNumericValue from MV and add/use RoundStringMVResult helper

 <h1>Static Semantics: MV</h1>         <h1>Static Semantics: NumericValue</h1>         <emu-grammar>NumericLiteral :: DecimalLiteral</emu-grammar>         <emu-alg>-          1. Return the Number value that results from rounding the MV of |DecimalLiteral| as described below.+          1. Return RoundStringMVResult(MV of |DecimalLiteral|).         </emu-alg>         <emu-grammar>NumericLiteral :: NonDecimalIntegerLiteral</emu-grammar>         <emu-alg>-          1. Return the Number value that results from rounding the MV of |NonDecimalIntegerLiteral| as described below.+          1. Return RoundStringMVResult(MV of |NonDecimalIntegerLiteral|).
          1. Return 𝔽(MV of |NonDecimalIntegerLiteral|).

As above, 20-digit rounding doesn't apply to non-decimal literals.

michaelficarra

comment created time in 9 hours

Pull request review commenttc39/ecma262

Editorial: extract StringNumericValue from MV and add/use RoundStringMVResult helper

 <h2>Syntax</h2>           </ul>         </emu-note> -        <emu-clause id="sec-runtime-semantics-mv-s">-          <h1>Runtime Semantics: MV</h1>-          <p>The conversion of a String to a Number value is similar overall to the determination of the Number value for a numeric literal (see <emu-xref href="#sec-literals-numeric-literals"></emu-xref>), but some of the details are different, so the process for converting a String numeric literal to a value of Number type is given here. This value is determined in two steps: first, a mathematical value (MV) is derived from the String numeric literal; second, this mathematical value is rounded as described below. The MV on any grammar symbol, not provided below, is the MV for that symbol defined in <emu-xref href="#sec-static-semantics-mv"></emu-xref>.</p>-          <ul>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: [empty]</emu-grammar> is 0.-            </li>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: StrWhiteSpace</emu-grammar> is 0.-            </li>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: StrWhiteSpace? StrNumericLiteral StrWhiteSpace?</emu-grammar> is the MV of |StrNumericLiteral|, no matter whether white space is present or not.-            </li>-            <li>-              The MV of <emu-grammar>StrDecimalLiteral ::: `-` StrUnsignedDecimalLiteral</emu-grammar> is the negative of the MV of |StrUnsignedDecimalLiteral|. (Note that if the MV of |StrUnsignedDecimalLiteral| is 0, the negative of this MV is also 0. The rounding rule described below handles the conversion of this signless mathematical zero to a floating-point *+0*<sub>𝔽</sub> or *-0*<sub>𝔽</sub> as appropriate.)-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `Infinity`</emu-grammar> is 10<sup>10000</sup> (a value so large that it will round to *+&infin;*<sub>𝔽</sub>).-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits</emu-grammar> is the MV of the first |DecimalDigits| plus (the MV of the second |DecimalDigits| times 10<sup>-_n_</sup>), where _n_ is the number of code points in the second |DecimalDigits|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_</sup>, where _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits ExponentPart</emu-grammar> is (the MV of the first |DecimalDigits| plus (the MV of the second |DecimalDigits| times 10<sup>-_n_</sup>)) times 10<sup>_e_</sup>, where _n_ is the number of code points in the second |DecimalDigits| and _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits</emu-grammar> is the MV of |DecimalDigits| times 10<sup>-_n_</sup>, where _n_ is the number of code points in |DecimalDigits|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_ - _n_</sup>, where _n_ is the number of code points in |DecimalDigits| and _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_</sup>, where _e_ is the MV of |ExponentPart|.-            </li>-          </ul>-          <p>Once the exact MV for a String numeric literal has been determined, it is then rounded to a value of the Number type. If the MV is 0, then the rounded value is *+0*<sub>𝔽</sub> unless the first non white space code point in the String numeric literal is `-`, in which case the rounded value is *-0*<sub>𝔽</sub>. Otherwise, the rounded value must be the Number value for the MV (in the sense defined in <emu-xref href="#sec-ecmascript-language-types-number-type"></emu-xref>), unless the literal includes a |StrUnsignedDecimalLiteral| and the literal has more than 20 significant digits, in which case the Number value may be either the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit or the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit and then incrementing the literal at the 20th digit position. A digit is significant if it is not part of an |ExponentPart| and</p>-          <ul>-            <li>-              it is not `0`; or-            </li>-            <li>-              there is a non-zero digit to its left and there is a non-zero digit, not in the |ExponentPart|, to its right.-            </li>-          </ul>+        <emu-clause id="sec-runtime-semantics-stringnumericvalue" aoid="StringNumericValue" oldids="sec-runtime-semantics-mv-s">
        <emu-clause id="sec-runtime-semantics-stringnumericvalue" type="sdo" aoid="StringNumericValue" oldids="sec-runtime-semantics-mv-s">
michaelficarra

comment created time in 9 hours

Pull request review commenttc39/ecma262

Editorial: extract StringNumericValue from MV and add/use RoundStringMVResult helper

 <h2>Syntax</h2>           </ul>         </emu-note> -        <emu-clause id="sec-runtime-semantics-mv-s">-          <h1>Runtime Semantics: MV</h1>-          <p>The conversion of a String to a Number value is similar overall to the determination of the Number value for a numeric literal (see <emu-xref href="#sec-literals-numeric-literals"></emu-xref>), but some of the details are different, so the process for converting a String numeric literal to a value of Number type is given here. This value is determined in two steps: first, a mathematical value (MV) is derived from the String numeric literal; second, this mathematical value is rounded as described below. The MV on any grammar symbol, not provided below, is the MV for that symbol defined in <emu-xref href="#sec-static-semantics-mv"></emu-xref>.</p>-          <ul>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: [empty]</emu-grammar> is 0.-            </li>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: StrWhiteSpace</emu-grammar> is 0.-            </li>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: StrWhiteSpace? StrNumericLiteral StrWhiteSpace?</emu-grammar> is the MV of |StrNumericLiteral|, no matter whether white space is present or not.-            </li>-            <li>-              The MV of <emu-grammar>StrDecimalLiteral ::: `-` StrUnsignedDecimalLiteral</emu-grammar> is the negative of the MV of |StrUnsignedDecimalLiteral|. (Note that if the MV of |StrUnsignedDecimalLiteral| is 0, the negative of this MV is also 0. The rounding rule described below handles the conversion of this signless mathematical zero to a floating-point *+0*<sub>𝔽</sub> or *-0*<sub>𝔽</sub> as appropriate.)-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `Infinity`</emu-grammar> is 10<sup>10000</sup> (a value so large that it will round to *+&infin;*<sub>𝔽</sub>).-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits</emu-grammar> is the MV of the first |DecimalDigits| plus (the MV of the second |DecimalDigits| times 10<sup>-_n_</sup>), where _n_ is the number of code points in the second |DecimalDigits|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_</sup>, where _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits ExponentPart</emu-grammar> is (the MV of the first |DecimalDigits| plus (the MV of the second |DecimalDigits| times 10<sup>-_n_</sup>)) times 10<sup>_e_</sup>, where _n_ is the number of code points in the second |DecimalDigits| and _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits</emu-grammar> is the MV of |DecimalDigits| times 10<sup>-_n_</sup>, where _n_ is the number of code points in |DecimalDigits|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_ - _n_</sup>, where _n_ is the number of code points in |DecimalDigits| and _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_</sup>, where _e_ is the MV of |ExponentPart|.-            </li>-          </ul>-          <p>Once the exact MV for a String numeric literal has been determined, it is then rounded to a value of the Number type. If the MV is 0, then the rounded value is *+0*<sub>𝔽</sub> unless the first non white space code point in the String numeric literal is `-`, in which case the rounded value is *-0*<sub>𝔽</sub>. Otherwise, the rounded value must be the Number value for the MV (in the sense defined in <emu-xref href="#sec-ecmascript-language-types-number-type"></emu-xref>), unless the literal includes a |StrUnsignedDecimalLiteral| and the literal has more than 20 significant digits, in which case the Number value may be either the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit or the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit and then incrementing the literal at the 20th digit position. A digit is significant if it is not part of an |ExponentPart| and</p>-          <ul>-            <li>-              it is not `0`; or-            </li>-            <li>-              there is a non-zero digit to its left and there is a non-zero digit, not in the |ExponentPart|, to its right.-            </li>-          </ul>+        <emu-clause id="sec-runtime-semantics-stringnumericvalue" aoid="StringNumericValue" oldids="sec-runtime-semantics-mv-s">+          <h1>Runtime Semantics: StringNumericValue</h1>+          <p>The conversion of a String to a Number value is similar overall to the determination of the Number value for a numeric literal (see <emu-xref href="#sec-literals-numeric-literals"></emu-xref>), but some of the details are different, so the process for converting a String numeric literal to a value of Number type is given here.</p>+          <emu-grammar>StringNumericLiteral ::: StrWhiteSpace?</emu-grammar>+          <emu-alg>+            1. Return *+0*<sub>𝔽</sub>.+          </emu-alg>+          <emu-grammar>StringNumericLiteral ::: StrWhiteSpace? StrNumericLiteral StrWhiteSpace?</emu-grammar>+          <emu-alg>+            1. Return StringNumericValue of |StrNumericLiteral|.+          </emu-alg>+          <emu-grammar>StrNumericLiteral ::: NonDecimalIntegerLiteral</emu-grammar>+          <emu-alg>+            1. Return RoundStringMVResult(MV of |NonDecimalIntegerLiteral|).+          </emu-alg>+          <emu-grammar>+            StrDecimalLiteral ::: StrUnsignedDecimalLiteral+            StrDecimalLiteral ::: `+` StrUnsignedDecimalLiteral

The two productions should be separated by an empty line.

Alternatively, you could drop this grammar+alg pair and let the chain rule handle it.

michaelficarra

comment created time in 9 hours

Pull request review commenttc39/ecma262

Editorial: extract StringNumericValue from MV and add/use RoundStringMVResult helper

 <h2>Syntax</h2>           </ul>         </emu-note> -        <emu-clause id="sec-runtime-semantics-mv-s">-          <h1>Runtime Semantics: MV</h1>-          <p>The conversion of a String to a Number value is similar overall to the determination of the Number value for a numeric literal (see <emu-xref href="#sec-literals-numeric-literals"></emu-xref>), but some of the details are different, so the process for converting a String numeric literal to a value of Number type is given here. This value is determined in two steps: first, a mathematical value (MV) is derived from the String numeric literal; second, this mathematical value is rounded as described below. The MV on any grammar symbol, not provided below, is the MV for that symbol defined in <emu-xref href="#sec-static-semantics-mv"></emu-xref>.</p>-          <ul>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: [empty]</emu-grammar> is 0.-            </li>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: StrWhiteSpace</emu-grammar> is 0.-            </li>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: StrWhiteSpace? StrNumericLiteral StrWhiteSpace?</emu-grammar> is the MV of |StrNumericLiteral|, no matter whether white space is present or not.-            </li>-            <li>-              The MV of <emu-grammar>StrDecimalLiteral ::: `-` StrUnsignedDecimalLiteral</emu-grammar> is the negative of the MV of |StrUnsignedDecimalLiteral|. (Note that if the MV of |StrUnsignedDecimalLiteral| is 0, the negative of this MV is also 0. The rounding rule described below handles the conversion of this signless mathematical zero to a floating-point *+0*<sub>𝔽</sub> or *-0*<sub>𝔽</sub> as appropriate.)-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `Infinity`</emu-grammar> is 10<sup>10000</sup> (a value so large that it will round to *+&infin;*<sub>𝔽</sub>).-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits</emu-grammar> is the MV of the first |DecimalDigits| plus (the MV of the second |DecimalDigits| times 10<sup>-_n_</sup>), where _n_ is the number of code points in the second |DecimalDigits|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_</sup>, where _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits ExponentPart</emu-grammar> is (the MV of the first |DecimalDigits| plus (the MV of the second |DecimalDigits| times 10<sup>-_n_</sup>)) times 10<sup>_e_</sup>, where _n_ is the number of code points in the second |DecimalDigits| and _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits</emu-grammar> is the MV of |DecimalDigits| times 10<sup>-_n_</sup>, where _n_ is the number of code points in |DecimalDigits|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_ - _n_</sup>, where _n_ is the number of code points in |DecimalDigits| and _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_</sup>, where _e_ is the MV of |ExponentPart|.-            </li>-          </ul>-          <p>Once the exact MV for a String numeric literal has been determined, it is then rounded to a value of the Number type. If the MV is 0, then the rounded value is *+0*<sub>𝔽</sub> unless the first non white space code point in the String numeric literal is `-`, in which case the rounded value is *-0*<sub>𝔽</sub>. Otherwise, the rounded value must be the Number value for the MV (in the sense defined in <emu-xref href="#sec-ecmascript-language-types-number-type"></emu-xref>), unless the literal includes a |StrUnsignedDecimalLiteral| and the literal has more than 20 significant digits, in which case the Number value may be either the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit or the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit and then incrementing the literal at the 20th digit position. A digit is significant if it is not part of an |ExponentPart| and</p>-          <ul>-            <li>-              it is not `0`; or-            </li>-            <li>-              there is a non-zero digit to its left and there is a non-zero digit, not in the |ExponentPart|, to its right.-            </li>-          </ul>+        <emu-clause id="sec-runtime-semantics-stringnumericvalue" aoid="StringNumericValue" oldids="sec-runtime-semantics-mv-s">+          <h1>Runtime Semantics: StringNumericValue</h1>+          <p>The conversion of a String to a Number value is similar overall to the determination of the Number value for a numeric literal (see <emu-xref href="#sec-literals-numeric-literals"></emu-xref>), but some of the details are different, so the process for converting a String numeric literal to a value of Number type is given here.</p>+          <emu-grammar>StringNumericLiteral ::: StrWhiteSpace?</emu-grammar>+          <emu-alg>+            1. Return *+0*<sub>𝔽</sub>.+          </emu-alg>+          <emu-grammar>StringNumericLiteral ::: StrWhiteSpace? StrNumericLiteral StrWhiteSpace?</emu-grammar>+          <emu-alg>+            1. Return StringNumericValue of |StrNumericLiteral|.+          </emu-alg>+          <emu-grammar>StrNumericLiteral ::: NonDecimalIntegerLiteral</emu-grammar>+          <emu-alg>+            1. Return RoundStringMVResult(MV of |NonDecimalIntegerLiteral|).+          </emu-alg>+          <emu-grammar>+            StrDecimalLiteral ::: StrUnsignedDecimalLiteral+            StrDecimalLiteral ::: `+` StrUnsignedDecimalLiteral+          </emu-grammar>+          <emu-alg>+            1. Return StringNumericValue of |StrUnsignedDecimalLiteral|.+          </emu-alg>+          <emu-grammar>StrDecimalLiteral ::: `-` StrUnsignedDecimalLiteral</emu-grammar>+          <emu-alg>+            1. Let _a_ be StringNumericValue of |StrUnsignedDecimalLiteral|.+            1. If _a_ is *+0*<sub>𝔽</sub>, return *-0*<sub>𝔽</sub>.+            1. Return -_a_.+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: `Infinity`</emu-grammar>+          <emu-alg>+            1. Return *+&infin;*<sub>𝔽</sub>.+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits? ExponentPart?</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of the first |DecimalDigits|.+            1. If the second |DecimalDigits| is present, let _b_ be MV of the second |DecimalDigits|. Otherwise, let _b_ be 0.+            1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0.+            1. Let _n_ be the number of code points in the second |DecimalDigits|.+            1. Return RoundStringMVResult((_a_ + (_b_ &times; 10<sup>-_n_</sup>)) &times; 10<sup>_e_</sup>).+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits ExponentPart?</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of |DecimalDigits|.+            1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0.+            1. Let _n_ be the number of code points in |DecimalDigits|.+            1. Return RoundStringMVResult(_a_ &times; 10<sup>_e_-_n_</sup>).+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPart?</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of |DecimalDigits|.+            1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0.+            1. Return RoundStringMVResult(_a_ &times; 10<sup>_e_</sup>).+          </emu-alg>+        </emu-clause>++        <emu-clause id="sec-roundstringmvresult" aoid="RoundStringMVResult">+          <h1>RoundStringMVResult ( _n_ )</h1>+          <p>The abstract operation RoundStringMVResult takes argument _n_ (a mathematical value). It converts _n_ to a Number in an implementation-defined manner. For the purposes of this abstract operation, a digit is significant if it is not zero or there is a non-zero digit to its left and there is a non-zero digit to its right. For the purposes of this abstract operation, "the mathematical value denoted by" a representation of a mathematical value is the inverse of "the decimal representation of" a mathematical value. It performs the following steps when called:</p>+          <emu-alg>+            1. If the decimal representation of _n_ has fewer than 20 significant digits, return 𝔽(_n_).
            1. If the decimal representation of _n_ has 20 or fewer significant digits, return 𝔽(_n_).

(or "fewer than 21", I suppose.) As is, if the decimal rep has exactly 20 sig digits, then option2 increments the 20th position, which is not currently allowed.

michaelficarra

comment created time in 9 hours

Pull request review commenttc39/ecma262

Editorial: extract StringNumericValue from MV and add/use RoundStringMVResult helper

 <h2>Syntax</h2>           </ul>         </emu-note> -        <emu-clause id="sec-runtime-semantics-mv-s">-          <h1>Runtime Semantics: MV</h1>-          <p>The conversion of a String to a Number value is similar overall to the determination of the Number value for a numeric literal (see <emu-xref href="#sec-literals-numeric-literals"></emu-xref>), but some of the details are different, so the process for converting a String numeric literal to a value of Number type is given here. This value is determined in two steps: first, a mathematical value (MV) is derived from the String numeric literal; second, this mathematical value is rounded as described below. The MV on any grammar symbol, not provided below, is the MV for that symbol defined in <emu-xref href="#sec-static-semantics-mv"></emu-xref>.</p>-          <ul>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: [empty]</emu-grammar> is 0.-            </li>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: StrWhiteSpace</emu-grammar> is 0.-            </li>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: StrWhiteSpace? StrNumericLiteral StrWhiteSpace?</emu-grammar> is the MV of |StrNumericLiteral|, no matter whether white space is present or not.-            </li>-            <li>-              The MV of <emu-grammar>StrDecimalLiteral ::: `-` StrUnsignedDecimalLiteral</emu-grammar> is the negative of the MV of |StrUnsignedDecimalLiteral|. (Note that if the MV of |StrUnsignedDecimalLiteral| is 0, the negative of this MV is also 0. The rounding rule described below handles the conversion of this signless mathematical zero to a floating-point *+0*<sub>𝔽</sub> or *-0*<sub>𝔽</sub> as appropriate.)-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `Infinity`</emu-grammar> is 10<sup>10000</sup> (a value so large that it will round to *+&infin;*<sub>𝔽</sub>).-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits</emu-grammar> is the MV of the first |DecimalDigits| plus (the MV of the second |DecimalDigits| times 10<sup>-_n_</sup>), where _n_ is the number of code points in the second |DecimalDigits|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_</sup>, where _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits ExponentPart</emu-grammar> is (the MV of the first |DecimalDigits| plus (the MV of the second |DecimalDigits| times 10<sup>-_n_</sup>)) times 10<sup>_e_</sup>, where _n_ is the number of code points in the second |DecimalDigits| and _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits</emu-grammar> is the MV of |DecimalDigits| times 10<sup>-_n_</sup>, where _n_ is the number of code points in |DecimalDigits|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_ - _n_</sup>, where _n_ is the number of code points in |DecimalDigits| and _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_</sup>, where _e_ is the MV of |ExponentPart|.-            </li>-          </ul>-          <p>Once the exact MV for a String numeric literal has been determined, it is then rounded to a value of the Number type. If the MV is 0, then the rounded value is *+0*<sub>𝔽</sub> unless the first non white space code point in the String numeric literal is `-`, in which case the rounded value is *-0*<sub>𝔽</sub>. Otherwise, the rounded value must be the Number value for the MV (in the sense defined in <emu-xref href="#sec-ecmascript-language-types-number-type"></emu-xref>), unless the literal includes a |StrUnsignedDecimalLiteral| and the literal has more than 20 significant digits, in which case the Number value may be either the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit or the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit and then incrementing the literal at the 20th digit position. A digit is significant if it is not part of an |ExponentPart| and</p>-          <ul>-            <li>-              it is not `0`; or-            </li>-            <li>-              there is a non-zero digit to its left and there is a non-zero digit, not in the |ExponentPart|, to its right.-            </li>-          </ul>+        <emu-clause id="sec-runtime-semantics-stringnumericvalue" aoid="StringNumericValue" oldids="sec-runtime-semantics-mv-s">+          <h1>Runtime Semantics: StringNumericValue</h1>+          <p>The conversion of a String to a Number value is similar overall to the determination of the Number value for a numeric literal (see <emu-xref href="#sec-literals-numeric-literals"></emu-xref>), but some of the details are different, so the process for converting a String numeric literal to a value of Number type is given here.</p>+          <emu-grammar>StringNumericLiteral ::: StrWhiteSpace?</emu-grammar>+          <emu-alg>+            1. Return *+0*<sub>𝔽</sub>.+          </emu-alg>+          <emu-grammar>StringNumericLiteral ::: StrWhiteSpace? StrNumericLiteral StrWhiteSpace?</emu-grammar>+          <emu-alg>+            1. Return StringNumericValue of |StrNumericLiteral|.+          </emu-alg>+          <emu-grammar>StrNumericLiteral ::: NonDecimalIntegerLiteral</emu-grammar>+          <emu-alg>+            1. Return RoundStringMVResult(MV of |NonDecimalIntegerLiteral|).+          </emu-alg>+          <emu-grammar>+            StrDecimalLiteral ::: StrUnsignedDecimalLiteral+            StrDecimalLiteral ::: `+` StrUnsignedDecimalLiteral+          </emu-grammar>+          <emu-alg>+            1. Return StringNumericValue of |StrUnsignedDecimalLiteral|.+          </emu-alg>+          <emu-grammar>StrDecimalLiteral ::: `-` StrUnsignedDecimalLiteral</emu-grammar>+          <emu-alg>+            1. Let _a_ be StringNumericValue of |StrUnsignedDecimalLiteral|.+            1. If _a_ is *+0*<sub>𝔽</sub>, return *-0*<sub>𝔽</sub>.+            1. Return -_a_.+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: `Infinity`</emu-grammar>+          <emu-alg>+            1. Return *+&infin;*<sub>𝔽</sub>.+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits? ExponentPart?</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of the first |DecimalDigits|.+            1. If the second |DecimalDigits| is present, let _b_ be MV of the second |DecimalDigits|. Otherwise, let _b_ be 0.+            1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0.+            1. Let _n_ be the number of code points in the second |DecimalDigits|.+            1. Return RoundStringMVResult((_a_ + (_b_ &times; 10<sup>-_n_</sup>)) &times; 10<sup>_e_</sup>).+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits ExponentPart?</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of |DecimalDigits|.+            1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0.+            1. Let _n_ be the number of code points in |DecimalDigits|.+            1. Return RoundStringMVResult(_a_ &times; 10<sup>_e_-_n_</sup>).+          </emu-alg>+          <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPart?</emu-grammar>+          <emu-alg>+            1. Let _a_ be MV of |DecimalDigits|.+            1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0.+            1. Return RoundStringMVResult(_a_ &times; 10<sup>_e_</sup>).+          </emu-alg>+        </emu-clause>++        <emu-clause id="sec-roundstringmvresult" aoid="RoundStringMVResult">+          <h1>RoundStringMVResult ( _n_ )</h1>

Since this operation is also used for NumericLiterals, where there isn't a String involved, you might want to remove "String" from the name.

michaelficarra

comment created time in 9 hours

Pull request review commenttc39/ecma262

Editorial: extract StringNumericValue from MV and add/use RoundStringMVResult helper

 <h2>Syntax</h2>           </ul>         </emu-note> -        <emu-clause id="sec-runtime-semantics-mv-s">-          <h1>Runtime Semantics: MV</h1>-          <p>The conversion of a String to a Number value is similar overall to the determination of the Number value for a numeric literal (see <emu-xref href="#sec-literals-numeric-literals"></emu-xref>), but some of the details are different, so the process for converting a String numeric literal to a value of Number type is given here. This value is determined in two steps: first, a mathematical value (MV) is derived from the String numeric literal; second, this mathematical value is rounded as described below. The MV on any grammar symbol, not provided below, is the MV for that symbol defined in <emu-xref href="#sec-static-semantics-mv"></emu-xref>.</p>-          <ul>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: [empty]</emu-grammar> is 0.-            </li>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: StrWhiteSpace</emu-grammar> is 0.-            </li>-            <li>-              The MV of <emu-grammar>StringNumericLiteral ::: StrWhiteSpace? StrNumericLiteral StrWhiteSpace?</emu-grammar> is the MV of |StrNumericLiteral|, no matter whether white space is present or not.-            </li>-            <li>-              The MV of <emu-grammar>StrDecimalLiteral ::: `-` StrUnsignedDecimalLiteral</emu-grammar> is the negative of the MV of |StrUnsignedDecimalLiteral|. (Note that if the MV of |StrUnsignedDecimalLiteral| is 0, the negative of this MV is also 0. The rounding rule described below handles the conversion of this signless mathematical zero to a floating-point *+0*<sub>𝔽</sub> or *-0*<sub>𝔽</sub> as appropriate.)-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `Infinity`</emu-grammar> is 10<sup>10000</sup> (a value so large that it will round to *+&infin;*<sub>𝔽</sub>).-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits</emu-grammar> is the MV of the first |DecimalDigits| plus (the MV of the second |DecimalDigits| times 10<sup>-_n_</sup>), where _n_ is the number of code points in the second |DecimalDigits|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_</sup>, where _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits ExponentPart</emu-grammar> is (the MV of the first |DecimalDigits| plus (the MV of the second |DecimalDigits| times 10<sup>-_n_</sup>)) times 10<sup>_e_</sup>, where _n_ is the number of code points in the second |DecimalDigits| and _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits</emu-grammar> is the MV of |DecimalDigits| times 10<sup>-_n_</sup>, where _n_ is the number of code points in |DecimalDigits|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: `.` DecimalDigits ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_ - _n_</sup>, where _n_ is the number of code points in |DecimalDigits| and _e_ is the MV of |ExponentPart|.-            </li>-            <li>-              The MV of <emu-grammar>StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPart</emu-grammar> is the MV of |DecimalDigits| times 10<sup>_e_</sup>, where _e_ is the MV of |ExponentPart|.-            </li>-          </ul>-          <p>Once the exact MV for a String numeric literal has been determined, it is then rounded to a value of the Number type. If the MV is 0, then the rounded value is *+0*<sub>𝔽</sub> unless the first non white space code point in the String numeric literal is `-`, in which case the rounded value is *-0*<sub>𝔽</sub>. Otherwise, the rounded value must be the Number value for the MV (in the sense defined in <emu-xref href="#sec-ecmascript-language-types-number-type"></emu-xref>), unless the literal includes a |StrUnsignedDecimalLiteral| and the literal has more than 20 significant digits, in which case the Number value may be either the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit or the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a 0 digit and then incrementing the literal at the 20th digit position. A digit is significant if it is not part of an |ExponentPart| and</p>-          <ul>-            <li>-              it is not `0`; or-            </li>-            <li>-              there is a non-zero digit to its left and there is a non-zero digit, not in the |ExponentPart|, to its right.-            </li>-          </ul>+        <emu-clause id="sec-runtime-semantics-stringnumericvalue" aoid="StringNumericValue" oldids="sec-runtime-semantics-mv-s">+          <h1>Runtime Semantics: StringNumericValue</h1>+          <p>The conversion of a String to a Number value is similar overall to the determination of the Number value for a numeric literal (see <emu-xref href="#sec-literals-numeric-literals"></emu-xref>), but some of the details are different, so the process for converting a String numeric literal to a value of Number type is given here.</p>+          <emu-grammar>StringNumericLiteral ::: StrWhiteSpace?</emu-grammar>+          <emu-alg>+            1. Return *+0*<sub>𝔽</sub>.+          </emu-alg>+          <emu-grammar>StringNumericLiteral ::: StrWhiteSpace? StrNumericLiteral StrWhiteSpace?</emu-grammar>+          <emu-alg>+            1. Return StringNumericValue of |StrNumericLiteral|.+          </emu-alg>+          <emu-grammar>StrNumericLiteral ::: NonDecimalIntegerLiteral</emu-grammar>+          <emu-alg>+            1. Return RoundStringMVResult(MV of |NonDecimalIntegerLiteral|).
            1. Return 𝔽(MV of |NonDecimalIntegerLiteral|).

In the current spec, the 20-digit rounding only applies to decimal literals. If you apply it to non-decimal literals, then there are cases where the spec would allow two valid outcomes where it currently only allows one, which would be a normative change.

michaelficarra

comment created time in 9 hours

issue closedfacebook/react

React 18 : Project dependency tree issue.

<!-- Ask a question or share feedback about the React 18 release here. -->

yarn run v1.22.5
$ react-scripts start

There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.

The react-scripts package provided by Create React App requires a dependency:

  "babel-jest": "^26.6.0"

Don't try to install it manually: your package manager does it automatically.
However, a different version of babel-jest was detected higher up in 
the tree:

  C:\Users\UNION\node_modules\babel-jest (version: 27.0.2)

Manually installing incompatible versions is known to cause hard-to-debug issues.

If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.

To fix the dependency tree, try following the steps below in the exact order:

  1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
  2. Delete node_modules in your project folder.
  3. Remove "babel-jest" from dependencies and/or devDependencies in 
the package.json file in your project folder.
  4. Run npm install or yarn, depending on the package manager you use.

In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:    

  5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
     This may help because npm has known issues with package hoisting which may get resolved in future versions.

  6. Check if C:\Users\UNION\node_modules\babel-jest is outside your 
project directory.
     For example, you might have accidentally installed something in 
your home folder.

  7. Try running npm ls babel-jest in your project folder.
     This will tell you which other package (apart from the expected 
react-scripts) installed babel-jest.

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file 
in your project.
That would permanently disable this preflight check in case you want 
to proceed anyway.

P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. 



- I'm not able to solve this issue, I did tried the following steps but it seems like I'm not getting this? Please give some suggestions, so that i could work on my project smoothly.

closed time in 10 hours

vaish567

issue commentfacebook/react

React 18 : Project dependency tree issue.

Support requests filed as GitHub issues often go unanswered. We want you to find the answer you're looking for, so we suggest the following alternatives:

Coding Questions If you have a coding question related to React and React DOM, it might be better suited for Stack Overflow. It's a great place to browse through frequent questions about using React, as well as ask for help with specific questions.

https://stackoverflow.com/questions/tagged/react

Talk to other React developers There are many online forums which are a great place for discussion about best practices and application architecture as well as the future of React.

https://reactjs.org/community/support.html

vaish567

comment created time in 10 hours

issue openedfacebook/react

React 18 : Project dependency tree issue.

<!-- Ask a question or share feedback about the React 18 release here. -->

yarn run v1.22.5
$ react-scripts start

There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.

The react-scripts package provided by Create React App requires a dependency:

  "babel-jest": "^26.6.0"

Don't try to install it manually: your package manager does it automatically.
However, a different version of babel-jest was detected higher up in 
the tree:

  C:\Users\UNION\node_modules\babel-jest (version: 27.0.2)

Manually installing incompatible versions is known to cause hard-to-debug issues.

If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.

To fix the dependency tree, try following the steps below in the exact order:

  1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
  2. Delete node_modules in your project folder.
  3. Remove "babel-jest" from dependencies and/or devDependencies in 
the package.json file in your project folder.
  4. Run npm install or yarn, depending on the package manager you use.

In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:    

  5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
     This may help because npm has known issues with package hoisting which may get resolved in future versions.

  6. Check if C:\Users\UNION\node_modules\babel-jest is outside your 
project directory.
     For example, you might have accidentally installed something in 
your home folder.

  7. Try running npm ls babel-jest in your project folder.
     This will tell you which other package (apart from the expected 
react-scripts) installed babel-jest.

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file 
in your project.
That would permanently disable this preflight check in case you want 
to proceed anyway.

P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. 



- I'm not able to solve this issue, I did tried the following steps but it seems like I'm not getting this? Please give some suggestions, so that i could work on my project smoothly.

created time in 11 hours

issue openedfacebook/react

Bug: Memory leak with setState lambda setting to previous state

Hi,

It seems that there is a memory leak issue when using the set state hook lambda syntax, and setting the state to the previous state. The set state lambda in this scenario seems to be retained and never garbage collected.

Please ignore the contrived example, it's intentionally whittled down to the exact issue. It's quite a common requirement in our application to subscribe to an rxjs observable in a useEffect hook, then update some state when events are received (but the data received might not always result in a state change). The lambda syntax is required in the set state call because current state would otherwise always be the default state due to the closure around it in the useEffect hook. Even if there was another way to do it to avoid the issue, it's still a surprising behaviour and makes it harder to fall into the 'pit of success'.

Reproduction below:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Memory leak repro</title>
    <script src="https://unpkg.com/react@17/umd/react.development.js"></script>
    <script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>

    <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
  </head>
  <body>
    <div id="root"></div>
    <script type="text/babel">
        function App() {
          const [someState, setSomeState] = React.useState(false);
          React.useEffect(() => {
             const interval = setInterval(() => {
               const a = []; 
               for (var i = 0; i < 1000; i++) {
                 a.push({}); //produce lots of garbage objects to make the leak easier to see
               }
               // memory leak when setting state to previous state
               // set state lambda is not garbage collected and retained along with all of its captured closures
               setSomeState(state => a.length > 0 ? state : !state);

               // no memory leak when setting state to something other than previous state
               // set state lambda (and it's closures) are garbage collected as expected
               // setSomeState(state => a.length == 0 ? state : !state);
              }, 100);
             return () => clearInterval(interval);
          }, []);
          return <div>Test Memory Leak</div>;
      }


      ReactDOM.render(
        <App/>,
        document.getElementById('root')
      );

    </script>
  </body>
</html>

The best memory profiler to see this is the 'Allocation instrumentation on timeline' mode in chrome devtools.

I have confirmed this also happens using production / minified bundles so it's not a dev build issue.

Right now as a workaround I need to use 'hacks' like useRef and forceUpdate implementations which is a real shame so keen to see this fixed.

Many thanks!

created time in 11 hours

release mamoe/mirai

v2.7-M1

released time in 11 hours

startedxandjiji/exevo-pan

started time in 12 hours

issue openedwhatwg/html

"Any other end tag"

https://html.spec.whatwg.org/multipage/parsing.html#scriptForeignEndTag

Any other end tag

I think there might be a spec bug here. html5lib-tests added tree-building tests of the form <math></p><foo>. That test in particular agrees with how Safari, Firefox, and Chrome parse that bit of HTML. The Gumbo and html5ever parsers disagree. My reading of the spec agrees with Gumbo and html5ever.

Essentially, should the </p><foo>

  1. cause the math element to be closed and HTML p and foo elements to be inserted as children of the body element; or
  2. insert an HTML p element and a MathML foo element as children of the math element?

If 1 (what the browsers do), where does (or should) the specification specify that?

created time in 12 hours

issue commentfacebook/react

Bug: Iterator as JSX children doesn't work right

The main situation where I'm bumping up against this limitation is when using Map and Set data structures for my state, and using something like iter-tools to iterate over Map.entries() to generate my elements. Having to materialise all of my Iterables into Arrays makes the JSX quite a bit more cluttered.

Jack-Works

comment created time in 13 hours

startedlightningtgc/MProgress.js

started time in 13 hours