3 ms·
Or C#'s var keyword, for that matter. Unfortunately, both will only work for local variables. I suspect this is one of the reasons there aren't any popular pers
by pmjordan 16y ago
Or C#'s var keyword, for that matter. Unfortunately, both will only work for local variables. I suspect this is one of the reasons there aren't any popular persistent data structure libraries around for these languages. At least the .NET/C# type system supports covariance/contravariance for functions ("delegates"). Plus, they managed to build F# on it.
- timrobinson 16y agoF# doesn't in fact make use of {co|contra}variance: it only needed generics. (Although F# used to run on .NET 1.x using its own implementation of generics - Don Syme designed both .NET generics and the F# language.) For type inference, you just need a sufficiently smart compiler, although it's much more useful if your language knows about generic types.
- pmjordan 16y agoThanks for clearing that up (I've yet to try F# in anger). I suppose pre-generics F# did similar type wrangling to Scala's?
- timrobinson 16y agoI don't know about Scala, but yes, wrangling describes well what F# used to do. I never used F# before .NET 2.0, but the techniques it used on 1.x could be interesting -- I'll see if I can find some old documentation... Edit: There used to be a paper describing the technique. I can't find it now, but here's an old Don Syme announcement related to it: http://www.mail-archive.com/dotnet-rotor@discuss.develop.com/msg00424.html http://www.mail-archive.com/dotnet-rotor@discuss.develop.com...