2

In languages that support currying, I can't think of many cases where using a tuple as function input parameters would be better than breaking the tuple apart into multiple parameters, which then allows you to enjoy the full power of currying. In which situations is keeping a tuple as function parameter better than breaking it apart? (Apart from the situation where the input originally was already in tuple form) Does such situation occur a lot in production code?

xji
  • 791

1 Answers1

5

There's multiple reasons:

  1. Some functions will return tuples and it's useful to compose such functions directly with other functions that accept tuples.

  2. Often when values are bundled in a tuple they're conceptually one unit, i.e. you almost always pass all of them together. In other words, there's certain functions you wouldn't curry often.

  3. It's trivial to write functions that turn a tuple-accepting function in a curried function and vice-versa, so it's never a big issue even if you need to curry a tuple-accepting function.

Doval
  • 15,487