Looks more like an architecture problem to me than a language one. There is
plenty of sugar available already

el.on("click", function(e) {....});

using the existing arrow syntax:

el.on("click", e => ...)

using a constant instead of a string (it is a flag after all...):

el.on(click, e => ...)

And for your object:

el.myplugin({....});

you can use a setter:

el.myplugin = {...}



On Sat, Jul 20, 2013 at 3: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 :: {....};
>
> Or even this: (one token lookahead required)
>
> el.on : "click", function() {....};
> el.myplugin : {....};
>
> So formal rule for CallExpression may look like as
>
> CallExpression :
>       MemberExpression Arguments or
>       MemberExpression '::' ArgumentList
>
> Not that much but can make it more readable.
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to