What is Functional Programming? Part 5, Bindings

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#.

Posted 10-05-2010 11:07 AM by Christopher Bennage


About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET


SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
NHibernate Profiler
Balsamiq Mockups
JetBrains - ReSharper
Web Sequence Diagrams
Ducksboard<-- NEW Friend!


Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers


Community Server (Commercial Edition)