jashkenas / coffeescript

Unfancy JavaScript
https://coffeescript.org/
MIT License
16.49k stars 1.99k forks source link

better support for curry #1886

Closed co-dh closed 12 years ago

co-dh commented 12 years ago
add = (x) -> (y) -> x + y 

add 3 4 will be parsed as add (3 4) , which apply 3 as a function to 4 . the only way to get parsed is :

add(3)(4)

which has too may braces.

I suggest to change the syntax, so white space is treated as application.

michaelficarra commented 12 years ago

add(3) 4 and (add 3) 4 both do what you want. White space is treated as application, it's just right-associative, not left-associative, which makes way more sense than the alternative.

co-dh commented 12 years ago

I don't agree right-associative makes more sense than left. suppose you are using CPS programming, as in http://en.wikipedia.org/wiki/Continuation-passing_style you'll find left-associative is a must. Also CPS is used a lot in node.js

shesek commented 12 years ago

You do realize that changing that would break practically any CS code ever written, right?

satyr commented 12 years ago

Try Roy.

co-dh commented 12 years ago

Thanks. Interesting. personally I prefer coffeescript's syntax.

On Wed, Nov 23, 2011 at 4:41 AM, Satoshi Murakami reply@reply.github.com wrote:

Try http://roy.brianmckenna.org.


Reply to this email directly or view it on GitHub: https://github.com/jashkenas/coffee-script/issues/1886#issuecomment-2846711

co-dh commented 12 years ago

If it's a mistake, the early we correct it, the better. Anyway, didn't coffee script breaks all javascript code that already written? Also, a simple convert could be write to convert right associative to leve associative.

yuchi commented 12 years ago

It's not a mistake, just a design-level decision. I believe coffee's wide audience is a little too wide for such a change. Have a look at this search of projects on github which use coffee-script ;)

erisdev commented 12 years ago

If you want Haskell, you know where to find it. ;D

In all seriousness, though, I think left-associative is a better fit for a language that means to retain JavaScript's semantics. The Wiki has a big list of other languages that compile to JavaScript, including a few versions of Haskell and OCaml, that might be a better fit for your needs.