On Sat, Jul 20, 2013 at 4:05 PM, Andrew Fedoniouk <[email protected]
> wrote:
> In typical JS code we can see things like these:
>
> el.on("click", function() {....});
> el.myplugin({....});
>
> The syntax noise above is obvious I think.
>
> In principle nothing prevents us to modify JS grammar so statements
> above can be rewritten as:
>
> el.on :: "click", function() {....};
> el.myplugin :: {....};
>
I disagree with the implication that this is a good use for "::" as new
syntax.
>
> Or even this: (one token lookahead required)
>
More then that, a whole new language that doesn't yet have existing grammar
rules...
>
> el.on : "click", function() {....};
> el.myplugin : {....};
>
If the function at the call site isn't the method of an object, both
examples above turn into code that is already completely valid JavaScript
in the existing grammar
Given:
function foo(o) { return o; }
The first turns into a labelled statement, followed by a comma operator
expression:
foo: "click", function() {}; // function() {}
The second turns into a label statement, followed by an empty block body:
foo: {}; // undefined
Rick
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss