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

Normative: Add Exponentiation Operator #318

Closed
wants to merge 1 commit into from

Conversation

rwaldron
Copy link
Contributor

No description provided.

@@ -10350,7 +10350,7 @@
<emu-note>
<p>The following are the only restricted productions in the grammar:</p>
<emu-grammar>
PostfixExpression[Yield] :
IncrementExpression[Yield] :
Copy link
Member

Choose a reason for hiding this comment

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

I know I'm bikeshedding here, but calling this production IncrementExpression really bothers me when two of the four possibilities is a decrement. The SpiderMonkey AST called this an UpdateExpression. Could we go with that instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I like that better. Update to follow

@rwaldron rwaldron force-pushed the exponentiation-operator branch 9 times, most recently from 0732ab1 to 042fdf8 Compare January 29, 2016 21:58
@anba
Copy link
Contributor

anba commented Feb 3, 2016

I still think we should use the default operator evaluation order for the exponentiation operator (tc39/proposal-exponentiation-operator#10). The current implementations in Edge and SpiderMonkey also use the default evaluation order.

var leftValue = {valueOf(){ print("left-value"); return 3; }};
var rightValue = {valueOf(){ print("right-value"); return 2; }};

// Output with current proposal:  "left", "leftValue", "right", "rightValue"
// Default operator evaluation order: "left", "right", "leftValue", "rightValue"
print((print("left"), leftValue )**(print("right"), rightValue));

@bterlson
Copy link
Member

bterlson commented Feb 4, 2016

@anba that is very good point. @rwaldron, thoughts? Seems confusing to have different evaluation order. Seems like what @anba suggests is in line with every other operator...

@rwaldron
Copy link
Contributor Author

rwaldron commented Feb 5, 2016

I can't really follow those notes in that issue because I don't think they're aligned with the latest version of the feature spec—I tried to matching things up, but I'm exhausted at the moment and that was a bad idea.

@rwaldron
Copy link
Contributor Author

rwaldron commented Feb 5, 2016

I see the order of ops now, that may have been me being overzealous in my "clean ups" and just overlooking the change in semantics. Thanks @anba

1. Let _rightValue_ be ? GetValue(_right_).
1. Let _base_ be ? ToNumber(_leftValue_).
1. Let _exponent_ be ? ToNumber(_rightValue_).
1. Return the result of <emu-xref href="#sec-applying-the-exp-operator" title>Applying the ** operator</emu-xref> with _base_ and _exponent_ as specified in <emu-xref href="#sec-applying-the-exp-operator"></emu-xref>.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@anba @bterlson updated!

Copy link
Member

Choose a reason for hiding this comment

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

Yessir, looks good!

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@anba thanks again for taking a look at this, your attention is always greatly appreciated :)

@rwaldron
Copy link
Contributor Author

rwaldron commented Feb 5, 2016

Rebased on dfeaa39

@bterlson bterlson closed this in 28bdf07 Feb 5, 2016
@bterlson
Copy link
Member

bterlson commented Feb 5, 2016

🎆

@ljharb
Copy link
Member

ljharb commented Feb 6, 2016

🎆 ** 🎆

@rwaldron
Copy link
Contributor Author

rwaldron commented Feb 6, 2016

Thanks everyone!
On Fri, Feb 5, 2016 at 7:08 PM Jordan Harband notifications@github.com
wrote:

[image: 🎆] ** [image: 🎆]


Reply to this email directly or view it on GitHub
#318 (comment).

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.

None yet

5 participants