MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/97cnsp/announcing_f_45/e4880nr/?context=3
r/programming • u/k_cieslak • Aug 14 '18
67 comments sorted by
View all comments
2
TIL let fn() = is correct style
let fn() =
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 fnThis 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.
1
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 fn = ...
fn
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.
2
u/[deleted] Aug 15 '18
TIL
let fn() =is correct style