Syntax Proposal: Anonymous Arguments
ljharb at gmail.com
Fri Sep 23 18:00:10 UTC 2016
In Scala, the ambiguity of the underscore causes lots of confusion when you
have nested functions - how is that handled in your proposal?
Bear in mind, I think it's a tough argument that `@ + 1` is so much better
than `n => n + 1` that it warrants its own syntax.
Separately, the "@" is reserved for an existing proposal, so you'd have to
come up with different syntax anyways.
On Fri, Sep 23, 2016 at 10:38 AM, Kenneth Powers <ken at 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)
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss