Syntax sugar for partial application

Jussi Kalliokoski jussi.kalliokoski at
Thu Apr 9 14:11:14 UTC 2015

On Thu, Apr 9, 2015 at 4:04 PM, liorean <liorean at> wrote:

> Do we really need it?
> Your «foo(1, ?, 2);» is equivalent to «a=>foo(1,a,2)».
> Your «foo(?, 1, ???);» is equivalent to «(a,...b)=>foo(a,1,...b)».
> Your «foo(1, ???, 2);» is equivalent to «(...a)=>foo(...[1,...a,2])».

Not exactly. Using the placeholder syntax, `this` remains context
dependent, whereas with your examples you get `null` as `this`.

This might not seem like such a big deal until you consider it in
combination with the proposed bind syntax [1].

Also in your examples, redefining `foo` will lead to different results. The
placeholder syntax has a lot more room for optimization in the JIT compiler
(the partially applied result is guaranteed to have no side effects for
example, so the compiler can create a version of the original function
where it can inline the specified arguments; less moving parts, easier to


> Also, the ? token is already taken by the ternary conditional
> operator. Do we really want to overload it here for a nullary
> operator/special form, when we have as low overhead syntax as we
> already do in fat arrows for doing the exact same thing?
> --
> David "liorean" Andersson
> _______________________________________________
> es-discuss mailing list
> es-discuss at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list