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

Parenless function calling #2

Open
gabejohnson opened this issue Jun 1, 2017 · 7 comments
Open

Parenless function calling #2

gabejohnson opened this issue Jun 1, 2017 · 7 comments

Comments

@gabejohnson
Copy link
Member

gabejohnson commented Jun 1, 2017

I like big butts, but not on my function calls

const sum3 = x => y => z => x+y+z;
sum3(1)(2)(3); // 6

Wouldn't it be nice to live in this world?

sum3 1 2 3; // 6

ASI is the big problem with this syntax.

sum3 1
     2
     3;

But maybe this could work

(sum3 1
      2
      3);

or this

sum3 1
   \ 2
   \ 3;

sum3 1 \
     2 \
     3;

I might prototype it in sweet.js to see where it goes.

@gabejohnson
Copy link
Member Author

Inspired by a strawman syntax in #1

@gabejohnson
Copy link
Member Author

Got schooled by the Founder. Maybe the \ could work.

@gabejohnson
Copy link
Member Author

gabejohnson commented Jun 2, 2017

\ is the string escape character and escapes line breaks if encountered by itself. Don't know if that would pose a problem in this case.

Although it would be in line with

var str = "multiple \
line \
string \
literal";

str // "multiple line string literal"

Python uses \ for line continuation as well.

@ScottFreeCode
Copy link

But maybe this could work

(sum3 1
     2
     3);

Surely a Lisp that compiles to JS and happens to have builtin currying already exists out there somewhere, right?

(Now I'm going to wonder if anyone has ever invented a Lisp with Haskell's type system. Haskell in Lisp's clothing.)

@gabejohnson
Copy link
Member Author

gabejohnson commented Jun 3, 2017

@ScottFreeCode the parens were just for ASI suppression. But that won't work. \ might do the trick though. It should be a separate proposal.

Surely a Lisp that compiles to JS and happens to have builtin currying already exists out there somewhere, right?

Hmmm...there must be something 😄

Haskell in Lisp's clothing

https://github.com/lexi-lambda/hackett

@aliceklipper
Copy link

tc39/ecma262#1062

@aliceklipper
Copy link

I hope ASI will be removed completely one day.

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

No branches or pull requests

3 participants