Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Introducing the New Features of F# 3.0

Introducing the New Features of F# 3.0

Leia em Português

This item in japanese

The upcoming release of .NET Framework 4.5 brings in several new features for F# 3.0 (F Sharp) language such as a new type attribute, triple-quoted string literals, auto-properties, and unused variable warnings in addition to the core features such as type providers and LINQ queries.

If you attach [<CLIMutable>] attribute, which is newly introduced in F# 3.0, to an F# record type, the compiler emits a default constructor and property setters into the generated Intermediate Language code for this type.

"[<CLIMutable>] attribute may help you with WPF data binding or Entity Framework scenarios", says Brian McNamara, Visual Studio F# Developer at Microsoft.

F# 3.0 introduces triple-quoted string literals, which means that every code between triple quotes is kept verbatim and hence there is no possibility for escaping. With the help of this feature, developers will be able to add XAML as a string literal and will be useful for embedding XML code as data in a program or for passing large strings as arguments to type providers.

"I've been coding in F# for 4 years now and I'm really glad to see F# as a fully supported language in Visual Studio and finally it is time for F# to become mainstream", says Nick, the lead engineer-architect of M-Brace

F# 3.0 consists of an improved usage of auto-property when compared to its previous version, with which developers will be able to make use of this feature in a single line of code as shown below

type MyClass() = member val Y = 0 with get, set,

In the above code, member val denotes auto-property and the value of Y is declared after =.

I have been using F# for 2+ years now, and absolutely love it. Having previously developed in C#, the initial switch was mind bending but well worth it, said Huw Simpson, Software Developer.

F# 3.0 introduces a new feature with which you can activate warning number 1182 using the command line option and the F# compiler warns you if there are any unused variables in your code. In Visual Studio 2012, you can activate this feature from the Build tab of the project properties dialog and adding --warnon:1182 to the Other flags field.

In a large project with 100K lines of code, unused variable warnings may help you find bugs, said McNamara, Visual Studio F# Developer at Microsoft.

Rate this Article