I read This article and i found it interesting.
To sum it up for those who don\'t want to read the entire post. The author implements a higher order function named Curry
One example: You have a function compare(criteria1, criteria2, option1, option2, left, right)
. But when you want to supply the function compare
to some method with sorts a list, then compare()
must only take two arguments, compare(left, right)
. With curry you then bind the criteria arguments as you need it for sorting this list, and then finally this highly configurable function presents to the sort algorithm as any other plain compare(left,right)
.
Detail: .NET delegates employ implicit currying. Each non-static member function of a class has an implicit this
reference, still, when you write delegates, you do not need to manually use some currying to bind this
to the function. Instead C# cares for the syntactic sugar, automatically binds this, and returns a function which only requires the arguments left.
In C++ boost::bind et al. are used for the same. And as always, in C++ everything is a little bit more explicit (for instance, if you want to pass a instance-member function as a callback, you need to explicitly bind this
).