Identitifers can be rebound in both F# compiled code and interactive code. It's different to mutation because although you give a new meaning to that name code from before still sees the old meaning. I like to think of it as creating a new binding that just happens to have the same name as an old one. Consinder the following code snippet:

1
2
3
4
5
6
7
8
#light
let main() =
    let x = "hello World"
    let printx() =
        printfn "%s" x
    printx()
    let x = 1
    printx()

When executed main will print "hello world" to the console twice. The fact we've later given a different meaning to "x" has no effect on this.

The easiest way to flush the interactive console is to use the #quit command. The process thats hosting that particular session will close down and visual studio will automatically start a new one for you, ensuring everything is nice and fresh.

By on 1/25/2008 11:07 PM ()

Robert,

Thanks for the explanation, it was very clear. Also thanks for suggesting #quit. I suppose I should have tried it, but for some reason I thought it would shut down the interactive window and make me restart VS – although in retrospect I have no idea why I thought that!

Mitchell

By on 1/26/2008 4:29 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper