15 points · by senthil_rajasek · 18y ago · 11 comments
__invoke
Now that should provide some entertaining debugging sessions.So you get a bunch of drawbacks and none of the real benefits, plus misrepresentation in the documentation.
Which necessitates this patch, which includes syntax changes, of course. This can only, ahem, be better.
Visual Basic?
Dim mapped = New Integer() {1, 2, 3, 4}.Select(Function(n) n * 2)
Dim myFunc = Function(x) mapped.ToList.IndexOf(x)
Console.WriteLine(myFunc(4)) ' prints 1 (i.e. second element, since mapped == {2,4,6,8}
.NET (and therefore Visual Basic) has had delegates, which are basically typesafe function pointers, since 2005.If you want real functional programming on the CLR, there's always F#, which is firmly in the ML family.
AFAIK on the CLR closures are converted into classes with a single randomly named method (and since invoking a method on a class is designed to be quite efficient, that means you shoulodn't pay much of a performance penalty). In other words, it mechanically, automatically does what Java programmers would do by hand.