On Fri, Sep 23, 2016 at 10:38 AM, Kenneth Powers <k...@kenpowers.net> wrote:
> I have a proposal for new syntax in ES inspired by the placeholder syntax in
> Scala Functions.
>
> Essentially, the idea would be to allow anonymous arguments. The most simple
> example would be a function which takes one argument (as far as the
> programmer is concerned):
>
>     [1, 2, 3].map(@ + 1)
>
> This would be the same thing as:
>
>     [1, 2, 3].map(n => n + 1)
>
> Just like in Scala, an anonymous function is created. This concept can be
> further extended in ES:
>
>     [1, 2, 3].reduce(@0 + @1, 0)
>
> Which would be the same thing as:
>
>    [1, 2, 3].reduce((sum, n) => sum + n, 0)
>
> Thoughts?

While I like really concise callbacks for simple cases like this, the
win over arrow functions is *so tiny* here.  map(@+1) vs map(x=>x+1)
is *3 characters* different; map(@0+@1) vs map((x,y)=>x+y) is 5.
Having to learn a new syntax for tiny functions that only gains an
extremely miniscule benefit in terms of code size is an extremely hard
sell.

Compound this with the fact that the @ glyph is already spoken for,
and you have an extreme uphill battle to deal with.

I suggest just living with the few extra characters that arrow
functions impose, and being happy we no longer have to type out
"function ... { return }". ^_^

~TJ
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to