tc39 / proposal-partial-application

Proposal to add partial application to ECMAScript
https://tc39.es/proposal-partial-application/
BSD 3-Clause "New" or "Revised" License
1.02k stars 25 forks source link

ambiguous syntaxes #10

Closed royling closed 5 years ago

royling commented 7 years ago

When mixing ? and ... tokens, I guess only a set of syntaxes are valid imaging how the parser is going to work. Would you mind confirming the validity of the following syntaxes?

const f = (...x) => x

const g = f(?, 0, ..., ?) // valid?
const h = f(..., ?, 0, ...) // invalid? seems ambiguous
rbuckton commented 6 years ago

Originally, I intended the above to be approximately the same as this:

const g = (a, b, ...c) => f(a, 0, ...c, b);
const h = (a, ...b) => f(...b, a, 0, ...b);

However, following discussions at the September TC39 meeting, I think the following restriction makes sense:

That would make both g and h above an error, though we could loosen this restriction slightly if we implement #5.

rbuckton commented 5 years ago

Closing as ... is currently disallowed as of the latest draft of this proposal.