One of the first things we learn about F# is that all values are immutable. This is where much of the power of functional programming is derived. There are however a couple of ways to change the value of an identifier. Let's examine how this is done and what the differences are.
First we are able to redefine identifiers within functions by using the let keyword. This is useful when you want to have intermediate values which will not be referenced later, so there is no need to give them their own names.
Now lets look at type and scope:
Notice that when redefining a value using the let keyword, we are able change the type and value of the identifier. In the third line, valName is of type seq
Now lets look at the mutable Keyword. This keyword shows how F# can be used for imperative programming. We simply put the word mutable after let to define the identifier and then use the left arrow (<-) to change the value.
When using the mutable keyword, we are not able to change the type of the identifier, just the value. Notice the error in the next example.
Another important note about mutable identifiers is that you can not change the value of the identifier from within a subfunction. The following example demonstrates the scope error.
Hopefully this helps to clarify mutable vs immutable in F#.
F# Mutable vs Redefine
WMDoDN
Have you seen the incredible lineup for WMDoDN? 6 sessions with 4 tracks will add up to an entire day of learning and meeting smart people. I have seen some of these guys before and they are some of the best in the area. Obviously come check out my F# session if you get a chance, but if not, take good notes on the others for me! I can't wait to see you all May 10! There will be some car pooling from Columbus to Grand Rapids, MI. Get in touch with me if you need more information on that. Get registered ASAP before it fills up!
F# VS Option
Before you start writing F# you need to know this. Don't waste time like I did! F# doesn't allow you to use tabs, even though white space is relevant because different editors use tabs differently. So I was sitting here kind of annoyed by having to line up spaces, when I had a semi-intelligent moment! Set the option in VS for the F# text editor to use spaces instead of tabs. This is probably obvious to everyone who has ever typed more than a couple of lines of F# code. in case you are sitting there hating spaces, set the Visual Studio option! Tools --> Options:
Presentation Zen - Garr Reynolds

This book is fantastic. Quick, easy, inexpensive, must read! It doesn't matter if you are presenting at the office, school, or some sort of user group. There is a bit of focus on technical presentations, but the ideas are good for all types. My slide decks go better after reading the first 2 chapters, and I witnessed the same results for friends.
Buy at Amazon:
http://rubyurl.com/Vcez
Also, check out Garr Reynolds blog for even more great ideas.
http://www.presentationzen.com/
Where am I this spring? Im F#ing everywhere!
So this is my F# Spring tour so far. I'm going to try and make each talk different so that if you happen to be at more than one event, you can catch something new. I'm so anxious to spread a basic understanding of the language, so that I can start talking about the cooler more in depth stuff - hopefully during the next round of code camps! More about that later. Get you a Code Camp or DoDN if you can, these things rock! I can't wait to see everyone!
Apr 12 - Talking F# at Pittsburgh Code Camp: http://www.pghdotnet.org/CodeCamp/default.htm
Also I'll be at the Pittsburgh Heros Happen Here on Apr 14 (ok so I try to go to all of them so I can meet new smart people. I'll be in the area after my talk on the 12th)
Apr 19 - F# session with James Bender at CODoDN
http://cinnug.org/cododn/
Apr 26 - Spreading my F# knowledge at Richmond Code Camp
http://richmondcodecamp.org/default.aspx
May 3 - Iowa Code Camp - Even more F# talks!
http://iowacodecamp.com/
May 10 - You guessed it, I'm talking F# at WMDoDN
http://www.wmdotnet.org/dodn08/
May 17 - I've submitted an F# talk but even if it isn't accepted, I'll be there meeting new people and learning new things!
http://www.dodn.org/
Twitxr
They say a picture is worth a thousand words so what happens when you add that to Twitter's 140 characters? Twitxr.com! - pronounced 'Twitcher'. You can snap a picture, email it to your personal address, add a comment (up to 140 chars) and it automatically posts to twitter! I can see this being overused by Twitter addicts (me!) It works the same for Facebook if you are interested in that, its just a setting.
My test post from the BlackBerry:
Twitxr - kinda cool - photo at http://twitxr.com/pandamoni...
CODoDN Acceptance
I wanted to post a quick update because I just got the email saying that my F# talk with James Bender has been accepted. Sweet! Looks like I'll be spending a lot of time working on that. Hopefully we'll get some pretty cool demos together. Judging by all of the twittering going on, there will be plenty of good talks so get registered ASAP!
Labels
- Presentations (4)
- F# (3)
- Travel (2)
- Books (1)
- CODoDN (1)
- Twitter (1)
- Visual Studio (1)