mattbierner / khepri

ECMAScript derived programming language
http://khepri-lang.com/
MIT License
67 stars 3 forks source link

Better generated code for curry of function expression #65

Closed mattbierner closed 10 years ago

mattbierner commented 10 years ago

We can convert to lets with function bodies instead of using bind.

(\x -> x * 2) @ 10

Generates

let x = 10 in \ -> x * 2;

This can be applied recursively and may discard values

static sideEffect;
(\x y -> x + y) @ 1 @ 2 @ (sideEffect());

generates

var x = 1,
    y = 2;
(function() {
    return (x + y);
});

sideEffect is never called. I feel this is the correct behavior.