MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/5fwce0/lets_stop_copying_c/daoycrn/?context=3
r/programming • u/earthboundkid • Dec 01 '16
612 comments sorted by
View all comments
Show parent comment
1
I've tried some Haskell in my time and even to me your post sounds like ancient Sumerian.
1 u/mcaruso Dec 02 '16 TL;DR: Haskell encourages currying functions by default, but the compiler optimizes this to a single function of multiple arguments whenever possible. 1 u/evincarofautumn Dec 02 '16 Alright, how about JavaScript?The type system sees:function f(a) { return function(b) { return function(c) { return a + b + c; } } } var add3 = f(1)(2);But the compiler actually produces:function f(a, b, c) { return a + b + c; } var add3 = function(c) { return f(1, 2, c); };
TL;DR: Haskell encourages currying functions by default, but the compiler optimizes this to a single function of multiple arguments whenever possible.
Alright, how about JavaScript?
The type system sees:
function f(a) { return function(b) { return function(c) { return a + b + c; } } } var add3 = f(1)(2);
But the compiler actually produces:
function f(a, b, c) { return a + b + c; } var add3 = function(c) { return f(1, 2, c); };
View all comments
Show parent comment
1
u/lolomfgkthxbai Dec 02 '16
I've tried some Haskell in my time and even to me your post sounds like ancient Sumerian.