F# 4.0 Preview |
Written by Kay Ewbank | |||
Tuesday, 02 December 2014 | |||
Microsoft has announced a pre-release version of F# 4.0 and the latest Visual F# Tools for Visual Studio 2015 Preview. A version of the F# development tools were included with the VS 2015 Preview download, but the versions that were included had been branched for stabilization some time ago, and the developers say they’ve have made significant progress since then. The F#4 is an early preview of what will be available in the final version. Among the new features are constructors as first-class functions. Until now there has been no way to treat a type constructor as an isolated function that could be passed around and composed with other functions. The new version treats constructors as first-class functions, with the same treatment as other traditional .NET methods. So rather than writing this: you can now write: The treatment of mutable values has been simplified. According to the Visual Studio F# team blog, “In the past, the ‘mutable’ keyword was used to designate a stack-based mutable value, and that value could be mutated using the <- operator. If the mutable value happened to be captured by a closure and a heap-based value was required, the ‘ref’ syntax was needed instead, and mutation was done via the := operator.” The team says that having distinct syntaxes led to some code inelegance and developer confusion due to not being able to work out ahead of time which approach was going to be required. With F# 4.0, developers can now just use the ‘mutable’ keyword for all mutable values, and the compiler will take care of the rest, creating a stack-based value if possible, otherwise implicitly converting to a ref cell - as in this example: Support has also been added for high-dimensional arrays. The .NET framework supports up to 32-dimensional arrays, but in the past F# only supported use of up to rank-4 arrays. This is now fixed – at least in the handling of arrays created in external libraries that rely on high-dimensional arrays. However, F# still doesn’t let you create and manipulate high-rank arrays directly within the language itself. Another improvement is support for static parameters to provided methods. In previous versions, you could supply static parameters to the top-level provided type, but all other provided types, methods, and properties had to be generated based on this single set of parameters. You can now give a single type declaration along with parameterized usage of methods. Other changes mean you can slice linked lists in the same way as for arrays for reading elements and creating sub-lists:
The FSharp.Core runtime has also benefited from a number of improvements, including normalized collections modules; faster generic comparison; better async stack traces; and a variety of performance improvements.
More InformationDownload Visual F# Tools 4.0 Preview Announcing a preview of F# 4.0 and the Visual F# Tools in VS 2015 Related ArticlesVisual Studio 14 Another Preview Not Dumping .NET - Microsoft's Method To be informed about new articles on I Programmer, install the I Programmer Toolbar, subscribe to the RSS feed, follow us on, Twitter, Facebook, Google+ or Linkedin, or sign up for our weekly newsletter.
Comments
or email your comment to: comments@i-programmer.info |
|||
Last Updated ( Tuesday, 02 December 2014 ) |