Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial Application: Stage 1 #32

Open
jamiebuilds opened this issue Sep 29, 2017 · 4 comments
Open

Partial Application: Stage 1 #32

jamiebuilds opened this issue Sep 29, 2017 · 4 comments

Comments

@jamiebuilds
Copy link

Champion: @rbuckton
Repo: https://github.com/rbuckton/proposal-partial-application
Slides: https://docs.google.com/presentation/d/1GSnqtT1jHbilIAwCuaK2yjKNj0y6cLfJNisZDig3Nm8/edit?usp=sharing
First presented at the Sept 2017 meeting

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`.

const maxGreaterThanZero = Math.max(0, ...);
maxGreaterThanZero(1, 2); // 2
maxGreaterThanZero(-1, -2); // 0

Syntax

f(x, ?)           // partial application from left
f(x, ...)         // partial application from left with rest
f(?, x)           // partial application from right
f(..., x)         // partial application from right with rest
f(?, x, ?)        // partial application for any arg
f(..., x, ...)    // partial application for any arg with rest
@jamiebuilds
Copy link
Author

Note that there were a number of concerns about the syntax in the Sept 2017 meeting. Particularly with how these are too similar:

fn(...b); // spread args, calls fn
fn(...,b); // placeholder, does not call fn

It was asked that there be a different syntax which is applied towards the start of a call:

<HERE>foo<OR_HERE>(x++)

But it was also raised that ... adds more complexity than it may be worth.

@hzoo hzoo mentioned this issue Sep 29, 2017
11 tasks
@ljharb
Copy link
Member

ljharb commented Sep 29, 2017

Additionally, a number of members raised concerns that it might not ever be possible for the syntax to be made viable to make it to stage 2.

@rajasekarm
Copy link
Member

I'll pick this.

@byara
Copy link

byara commented Jan 15, 2019

Hi, I would like to work on this. One thing, I'm going to learn a lot, the other, I'm writing my Bachelor thesis about Babel compiler so doing something for Babel would mean a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants