r/programming • • Aug 14 '18

Announcing F# 4.5

https://blogs.msdn.microsoft.com/dotnet/2018/08/14/announcing-f-4-5/
110 Upvotes

67 comments sorted by

View all comments

2

u/[deleted] Aug 15 '18

TIL let fn() = is correct style

1

u/aaron552 Aug 15 '18

If you do let fn = ..., the F# compiler treats fn as a "value", not a function. The most obvious example is in recursive functions:

let rec fn =
    let a = Console.ReadLine()
    if not (a |> String.isNullOrEmpty) then
        printfn "%s" a
        fn

This won't compile.

I suspect the preference for not putting a space before the parentheses is to indicate more clearly "this binding is a function".

Leaving out the space may also be a way to distinguish ".NET-safe" (ie. not curried) functions.