> ... I'd like to write this, but this doesn't work:

1
2
3
type Test (mutable x : int) = 
    member t.Bla y = 
        x <- x + y

IMHO, this doesn't seem like a good idea.
If I glanced at the above I would expect that "x" was a local c'tor variable, and would expect its value to disappear after the assignment.

While with:

1
2
3
4
type Test (x : int) = 
    let mutable x = x 
    member t.Bla y = 
        x <- x + y

it is obvious that we have a closure around the mutable.

thanks,
mike

By on 5/8/2009 12:20 PM ()

I think that a novice might expect the second option to act like the third option.

By on 5/7/2009 4:39 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