Fun with Generics - Currying
Sriram writes about aninteresting use of C# 2.0 Generics to implement "Currying," a technique which is normally reserved for functional programming languages.
Currying is the use of virtual functions which fix an function argument to a value and remove the argument:
In computer science,
currying is the technique of transforming a function
taking multiple arguments
into a function that takes a single argument (the first of the arguments to the
original function) and returns a new function that takes the remainder of the
arguments and returns the result. The technique was named by Christopher
Strachey after logician Haskell Curry, though it
was invented by Moses Schönfinkel
and Gottlob Frege.
Intuitively, currying says "if you fix some arguments, you get a function of the remaining arguments". So if you take the function in two variables yx, and fix y = 2, then you get the function in one variable 2x.
[Wikipedia]It seems a lot more academic than practical to me, but it's interesting to see what the kind of thing that C# Generics will enable.