I don't think that you can use static fields.

But you can use using something like :

1
2
3
4
5
6
7
8
9
 

let _hidden = ref 0 //to hide in the signature so that it is not accessible from uotside the module

type my_class () =
  static member run() = 
    incr _hidden 
    !hidden

or in a function :

1
2
3
4
5
let increment =
  let _hidden = ref 0
  fun step -> 
    _hidden := !_hidden + step 
    !_hidden

(an example with collections can be found at :
[link:blogs.msdn.com] )

Hope this helps

By on 9/13/2007 12:06 AM ()

Yes, you currently use a mutable or "ref" in a module.

We agree this is a bit of a pain since it can need to a needless extra module and also recursion problems (sometimes you have to give the field a type involving "obj" to avoid the latter, adding box and unbox). As a result static declarations in classes are planned for inclusion.

Kind regards

don

By on 9/13/2007 2:52 AM ()
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