Skip to content

Uncurry optimization  #479

@Fresheyeball

Description

@Fresheyeball

I made this jsPerf as a test http://jsperf.com/curry-cost

The automatic currying of functions is an awesome part of this language and functional in general. But in javascript it comes at a serious cost (particularly if your paradigm is to use shit tons of function application).

Some languages (Fay and Elm) flatten out curries at compile time if they are not used. So

  add3 x y z = x + y + z
  trace 1 2 3

instead of becoming:

   var add3 = function(x){
         return function(y){
               return function(z){
                      return x + y + z;
               };
         };
   };
   trace(add3(1)(2)(3));

becomes:

 var add3 = function(x,y,z){
       return x + y + z;
 };
 trace(add3(1,2,3));

are there any plans to add optimization around currying? I believe this could be done without breaking changes.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions