Syntax Proposal: Anonymous Arguments

Claude Pache claude.pache at gmail.com
Mon Sep 26 10:59:25 UTC 2016


> Le 23 sept. 2016 à 20:35, Kenneth Powers <ken at kenpowers.net> a écrit :
> 
> As for resolving ambiguity, why not just do what Scala does <http://stackoverflow.com/questions/19916169/scala-arguments-of-nested-lambdas-with-short-syntax/19917720>? It would seem to me that nesting these functions would be a sign you need to refactor anyway. 

Concretely, when you write:

```js
listOfNumbers.map(Math.floor(@) + 1)
```

what does it mean:

```js
_ => listOfNumbers.map(Math.floor(_) + 1) // (1)
listOfNumbers.map(_ => Math.floor(_) + 1) // (2)
listOfNumbers.map(Math.floor(_ => _) + 1) // (3)
```

? Although the most reasonable interpretation for a human would be (2), because the parser is unable to read your mind or to make a qualitative distinction between `listOfNumbers.map ` and `Math.floor` (both are just functions), it will most probably misinterpret it as (3).

That syntax looks like an attractive nuisance to me.

—Claude

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160926/09a5697f/attachment.html>


More information about the es-discuss mailing list