Cover by Oliver Sturm

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

DECOUPLING PARAMETERS

Function or method calls can accept parameters — that is true in almost all programming languages. The underlying mechanisms to transfer the parameters and to make them available to the code executed in the function or method vary, and so does the terminology used to describe this process.

In most .NET languages the parameter list that is declared for a particular function is static. That means that the function in question can only be called with all the parameters at once. In fact, the notion of calling a function with an incomplete list of parameters probably strikes many C# programmers as rather odd. Nevertheless, this is exactly what currying is all about: splitting up the parameter list, so it becomes possible to call functions with an incomplete set of parameters.

You might think at this point that object oriented languages, or even imperative languages in general, have their own mechanisms for the purpose of providing convenient variants of functions or methods, for those cases where the standard implementations are found to be too complex to use. This is an absolutely correct association. Mechanisms like method overloading or extension methods have a similar purpose. However, the functional alternatives have advantages when it comes to function level reuse and modularization, which makes them an interesting option.

Manual Currying

Currying is a transformation technique that starts with a function with multiple parameters and converts it into a sequence ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required