F# 4.5 Adds Span Support
Written by Kay Ewbank   
Thursday, 16 August 2018

There's an update to F#. While Microsoft remains the main driver behind the language, the F# team at Microsoft says Version 4.5 has been developed entirely via an open RFC process, with significant contributions from the community, especially in feature discussions and demonstrating use cases.

F# provides support for functional programming in addition to traditional object-oriented and imperative (procedural) programming. F# runs on Linux, Mac OS X, Android, iOS, Windows, GPUs, and browsers. Microsoft includes Visual F# in Visual Studio, and the language is also open source under an OSS-approved license and is available across multiple platforms through the F# Open Source Group.

The main change to the updated release is a set of features designed to work with the new Span feature in .NET Core 2.1.The Span feature is specific to .NET.  System.Span<T> is a new value type that can be used to represent contiguous regions of arbitrary memory, regardless of whether that memory is associated with a managed object, is provided by native code via interop, or is on the stack.

The F# feature set for span consists of a voidptr type, and functions in FSharp.Core to work with the type. You can also produce span structures, work with them, and write extension methods on them. The Microsoft F# team says the main goals for this feature set are:

  • Offer ways to interoperate with and product high-performance code in F#.
  • Full parity with .NET Core performance innovations.
  • Better code generation, especially for byref-like constructs.

Discussing the new feature, Phillip Carter of the F# team at Microsoft said:

"In practical terms, what all this means is that F# now has a feature set that allows for safe use of performance-oriented constructs in a very restrictive manner."

It is true that the span features are very restrictive. For example, you can't define an F# record type that has a Span inside of it. This is because a Span is a “byref-like” type, and byref-like types can only contained in other byref-like types. Fortunately, the compiler checks for safe use of span.

Other changes in this version include support for the match! keyword in computation expressions to simplify boilerplate code; and better async stack traces so that the reported line numbers now correspond to the failing user code, and non-user code is no longer emitted.

F# 4.5 is available via the latest .NET SDK, or in Visual Studio 2017 update 15.8. Non-Windows users working in Visual Studio for Mac or Visual Studio Code with Ionide get support F# 4.5 so long as the .NET SDK is installed.

 

fsharp

 

More Information

FSharp Organization

Related Articles

F# 4.0 Signals A Culture Change

F# 4.0 Preview

Update for Try F#

F# 3.0 - Worth A Try

F# is Open Source - sort of

Visual Studio 2015 Launched - Any App Any Developer

Full Visual Studio Now Free

Not Dumping .NET - Microsoft's Method

Microsoft Open Sources .NET?

 

 

Real-World F# - a free book 

Try F# website

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


Kotlin Ktor Improves Client-Server Support
04/11/2024

Kotlin Ktor 3 is now available with better performance and improvements including support for server-sent events and CSRF (Cross-Site Request Forgery) protection.



Improved Code Completion With JetBrains Mellum
29/10/2024

JetBrains has launched Mellum, a proprietary large language model specifically built for coding. Currently available only with JetBrains AI Assistant, Mellum is claimed to provide faster, sm [ ... ]


More News

espbook

 

Comments




or email your comment to: comments@i-programmer.info