2 ms·
First C++ and now PHP. What will be the next language to get functional closures? Visual Basic?
by mleonhard 18y ago
First C++ and now PHP. What will be the next language to get functional closures?
Visual Basic?
- halo 18y agoAlmost certainly Java 7.
- henning 18y agoUh, Visual Basic 20008/9.0 has lambda expressions built right in. 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.