This is a bug that has been fixed in our working tree and will be availble in the next release. In the current release members are only mutually recursive within a single class.

One workaround is to use more primitive constructors, then define a set of mutually recursive functions, then finally define "Create" methods with augmentations. A little awkward but not too bad. In the example below I've adjusted the code so that the mutual references are delayed through a function value.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 

type t = 
    class    
        val vu : unit -> u 
        new (vu) = { vu = vu } 
    end
and u = 
    class 
        val vt : unit -> t 
        new (vt) = { vt = vt } 
    end

let rec mkT () = new t(fun () -> mkU ())
and     mkU () = new u(fun () -> mkT ())

type t 
    with 
        static member Create() = mkT()
    end
type u 
    with
        static member Create() = mkU()
    end

By on 11/16/2006 4:28 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