Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make arguments optional #152

Closed
wants to merge 2 commits into from
Closed

Make arguments optional #152

wants to merge 2 commits into from

Conversation

jessealama
Copy link
Collaborator

Our intention for toFixed and toPrecision is to allow them to take no arguments, similar to how those methods work on Numbers. I wrestled with ecmarkup to get the notation right for that, trying various things, but nothing worked. As a consequence, the best I could do was to make the first argument mandatory and the second argument optional. But there is a way! And here it is. Thanks to @ben-allen for the solution.

Since this is a normative change, please do not merge this PR until after the next TC39 plenary.

jessealama and others added 2 commits June 1, 2024 11:25
Also, take just a single parameter for `toString` rather
than an options bag. We may discover a need for additional
options, but for now, canonicalization is the only one.
@jessealama jessealama requested a review from ptomato June 1, 2024 09:37
<p>This method generates a String representation of the current Decimal128 object, in decimal format. Unlike Number’s <emu-xref href="#sec-number.prototype.tostring">toString</emu-xref>, this method always produces a decimal representation of the Decimal128 object and never produces an exponential representation. That functionality is provided by <emu-xref href="#sec-decimal.prototype.toexponential">toExponential</emu-xref>.</p>
<p>It performs the following steps when called:</p>
<emu-alg>
1. Let _O_ be the *this* value.
1. Perform ? RequireInternalSlot(_O_, [[Decimal128Data]]).
1. Let _shouldCanonicalize_ be ? Get(_options_, *"canonicalize"*).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change? Seems unrelated.

@@ -656,7 +655,7 @@ location: https://github.com/tc39/proposal-decimal/
</emu-clause>

<emu-clause id="sec-decimal.prototype.tofixed">
<h1>Decimal128.prototype.toFixed ( _numDigits_ [ , _shouldCanonicalize_ ] )</h1>
<h1>Decimal128.prototype.toFixed ( [ _numDigits_ [ , _shouldCanonicalize_ ] ] )</h1>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the change is just the .length of the function? LGTM, IMO this change can be landed even though plenary is happening now.

Copy link
Collaborator

@ptomato ptomato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

I have some reservations about making toString's argument not be an options bag, but that seems like a discussion to have in stage 2.

@jessealama
Copy link
Collaborator Author

This is handled by the work done in #158

@jessealama jessealama closed this Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants