N.B. this is unrelated to the concept of bindings in Silverlight and WPF.
One of my aha moments in learning F# occurred while I was reading Real World Functional Programming. Specifically, it was when the meaning of the
let keyword really clicked. Before I explain, here are couple of samples:
let x = 42
let multiply a b = a * b
I was predisposed to interpret
let as merely declaring a variable. but you will recall from the first post that we made a distinction between working with mutable “variables” and immutable “values”. Functional languages eschew mutability.
If you look up
let in the official documentation and you’ll see that it is called a binding and it is very clearly described:
A binding associates an identifier with a value or function. You use the let keyword to bind a name to a value or function.
This also aligns with the concept of referential transparency we mentioned way back in the first post.
This may seem obvious or even a subtle distinction to make, but I think it is fundamental in understanding the functional approach.
Update: This next part is not technically accurate and I do not mean to imply that it is. Rather, this is how my poetic eye has begun to see the code.
After this clicked with me, I also to think of
let x = 42
as a function with no arguments that returns a value of 42. The distinction between binding to a value and binding to a function blurs (for me). It is the Marriage of Value and Function.
Next stop, pattern matching in F#.