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


NetMarketShare Bows Out
04/11/2020

This news item was supposed to be about the latest desktop browser statistics and the fact that during October Edge had experienced an increase in its share. However, more newsworthy is the fact the O [ ... ]



Nvidia's AI Supercomputer For Medical Research And Drug Discovery
18/11/2020

Last month Nvidia unveiled plans to build a supercomputer intended for AI research in health care. This prompts us to look at AI's potential role in health care and how it is already being used.

 [ ... ]


More News

square

 



 

Comments




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