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

NewExpression -> MemberExpression (for unary form) #9

Closed
wants to merge 1 commit into from

Conversation

dead-claudia
Copy link
Contributor

#4: No good use case for it.

There are only two possible use cases for ::func:

  1. You want to bind the function to undefined so it cannot be re-bound by the caller.
    • Use undefined::func or func.bind(undefined) as it's more explicit of the intent.
  2. You just want to pass the function as an argument.
    • Binding is unnecessary here. Just use func.

Because ::func ~ func.bind(undefined), func() ~ undefined::func(), and the above two points, there is no good use case for this.

tc39#4: No good use case for it.

There are only two possible use cases for `::func`:

1. You want to bind the function to `undefined` so it cannot be re-bound by the caller.
  - Use `undefined::func` or `func.bind(undefined)` as it's more explicit of the intent.
2. You just want to pass the function as an argument.
  - Binding is unnecessary here. Just use `func`.

Because `::func` is equivalent to `func.bind(undefined)`, and `func()` is equivalent to `undefined::func()`, there is no other use case for this.
@zenparsing
Copy link
Member

Changing "NewExpression" to "MemberExpression" in the grammar will still actually allow things like:

::ident;

#4 will have to be addressed with either:

  1. A runtime error if the operand is not a property reference, or
  2. An early error if the operand is neither MemberExpression : MemberExpression . Identifier nor MemberExpression : MemberExpression [ Expression ]

I think I'm going to go with option 2 for now.

@zenparsing
Copy link
Member

I went ahead and added the early error rule. Take a look and let me know if you have any suggestions!

@zenparsing zenparsing closed this May 16, 2015
@dead-claudia
Copy link
Contributor Author

Ok...overlooked that part. I must have confused it with ESTree's MemberExpression. Sorry about that.

@dead-claudia dead-claudia deleted the patch-1 branch May 17, 2015 12:33
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.

2 participants