I took a look here: Scala currying vs partially applied functions, but the answers there answer more about the functional and semantic differences between currying, partial application, and normal functions in Scala.
I'm interested in learning whether there are any performance considerations between these different techniques that can be used on functions, namely...
If we use the performance of a normal function as a base:
def add3(a: Int, b: Int, c: Int) = a + b + c
add3(1, 2, 3)
And then compare to:
// First
(add3 _).curried(1)(2)(3)
// Second
val add2 = add3(1, _: Int, _: Int)
val add1 = add2(2, _: Int)
add1(3)
// Third
def add3(a: Int)(b: Int)(c: Int) = a + b + c
add3(1)(2)(3)
What are the things I might want to be mindful of if I've identified some poorly performing code (either in terms of speed or memory usage) and I see a lot of currying or partial application happening in said code segment?
In Haskell I would, for instance, be looking at how many thunks are being generated and hanging around. I'd presume Scala uses a similar sort of method for passing around partially applied and curried functions, and the details of how Scala handles these things would be valuable to know.