On Sat, Jul 20, 2013 at 2:21 PM, Michael Haufe <[email protected]> wrote:
> 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 => ...)

That, indeed, may reduce noise but with proposed change
all this will look even cleaner:

el.on : click, e => $(this).addClass("clicked");

>
> And for your object:
>
> el.myplugin({....});
>
> you can use a setter:
>
> el.myplugin = {...}
>

Unfortunately setters do not work with jQuery where
chained calls are used frequently:

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

that with new syntax may look like as:

el.myplugin: { params }
  .addClass: "myplugin";


--
Andrew Fedoniouk.

http://terrainformatica.com


>
>
> 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