-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Labels
i: needs triageoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue
Description
This proposal introduces a new syntax using the ? token in an argument list which allows you to partially apply an argument list to a call expression by acting as a placeholder for an argument.
Info
Stage: 1
Champion: Ron Buckton (@rbuckton)
Proposal repo: https://github.com/tc39/proposal-partial-application
Example
const addOne = add(1, ?); // apply from the left
addOne(2); // 3
const addTen = add(?, 10); // apply from the right
addTen(2); // 12
// with pipeline
let newScore = player.score
|> add(7, ?)
|> clamp(0, 100, ?); // shallow stack, the pipe to `clamp` is the same frame as the pipe to `add`.
// partial template strings
const Diagnostics = {
unexpected_token: `Unexpected token: ${?}`,
name_not_found: `'${?}' not found.`
};
Diagnostics.name_not_found("foo"); // "'foo' not found."Basic Rules
- can be used one or more at the top level of the Arguments of a
CallExpression,CallMemberExpression, orSuperCall(e.g.f(?)oro.f(?)) - can be used in place of a
TemplateMiddleList
ESTree/Parsing
- I guess we can use the token
question - we can create a
Partialnode inparseExprListItemfunction
Transform
We will add Partial node to the AST and it will be added to the spec.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
i: needs triageoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue