Thoughts on Partial Application

Michael Rosefield rosyatrandom at gmail.com
Mon Dec 4 13:03:28 UTC 2017


I was looking through the notes on the last meeting, in particular the bit
about Partial Application:
http://rwaldron.github.io/tc39-notes/2017-09_sep-28.html#13i-partial-application

The current sticking point was that the syntax looked like a function call
instead of function definition, but my first thought was that this could be
fixed by using a simple token either before the function name, or between
it and the brackets.

For example, given a current function foo, the current proposal would have

const bar = foo(1, ?) // roughly: bar = x => foo(1,x)

While the choice of token is arbitrary, I'll go with '@' (Because I've got
to pick something, and it kind of suggests application. It's not important!
). I would suggest having one of these two as Partial Application syntax:

const bar = @foo(1, ?)
const bar = foo@(1, ?) // my preferred version

Are there any issues with solving the issue in this manner? I know that
adding new syntax unnecessarily should be avoided, but this is for clarity.

Another that's occurred to me is to allow a shorthand for arrow functions:

const baz1 = (x, 1, ...y) => foo(x, 1, ...y)
const baz2 = (?, 1, ...) => foo // shorthand for above

This would require parsing to check the RHS is just a function identifier,
but does suggest the intent of a function that passes arguments to a
function.

Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20171204/55703871/attachment.html>


More information about the es-discuss mailing list