In Lisp it makes sense to allow binding keywords because there's no such thing
as a keyword: once you bind it, it's a variable and you can refer to it. In JS
it's impossible to refer to it as a variable so it's just an (un)attractive
nuisance.
The only place where I could see this being arguably useful in ES6 is:
// foo.js
export function function() { }
// main.js
module foo from "foo";
foo.function();
But that's still probably not advisable, since it means you can't import the
name:
import { function } from "foo";
// d'oh
So I don't see any reason why a person shouldn't just use rebinding for that
use case:
// foo.js
function function_() { }
export { function_ as function };
To wit: I say leave it out.
Dave
On Aug 21, 2013, at 4:13 PM, Jason Orendorff <[email protected]> wrote:
> The ES6 draft says:
>
> MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody }
> PropertyName : IdentifierName
>
> This means a method name can be a keyword: `obj = {if() {}}`. This is
> consistent with other property names (`{if: true}` is allowed), but
> inconsistent with other function names (`function if(){}` is not
> allowed).
>
> Why not allow keywords as function names, too?
>
> -j
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss