Syntax sugar for partial application
jussi.kalliokoski at gmail.com
Thu Apr 9 07:46:12 UTC 2015
Yesterday I came up with an idea for syntactic sugar for partial
application, introducing two new operators: placeholder (`?`) and rest
You can see the details in a proposal gist I made , but the gist of the
gist is that you could do partial application like this:
foo(1, ?, 2);
or with the rest placeholder:
foo(?, 1, ???);
This allows for partial application at arbitrary argument indices.
There's a cowpath to be paved here as well, lodash introduced placeholders
for _.partial as of 3.0.0 , where you can do something similar:
_.partial(foo, 1, _, 2);
_.partial(foo, _, 1);
However, the proposed syntax is even more flexible than that of lodash
because it also allows you to have rest placeholders at arbitrary argument
indices instead of at the end, e.g.
foo(1, ???, 2);
would have to be expressed with lodash as
_.partialRight(_.partial(foo, 1), 2);
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss