Syntax sugar for partial application

Jussi Kalliokoski jussi.kalliokoski at
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
placeholder (`???`).

You can see the details in a proposal gist I made [1], 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 [2], 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...
URL: <>

More information about the es-discuss mailing list