5

考虑两个抽象类 alpha 和 beta:

[<AbstractClass>]  
type alpha () =
    abstract member foo: beta->beta

[<AbstractClass>] 
and beta () = //***
    abstract member bar: alpha

如果我尝试编译我得到一个错误,在 * * * 指示的行上:

error FS0010: Unexpected keyword 'and' in interaction

如果我写:

[<AbstractClass>]  
type alpha () =
    abstract member foo: beta->beta

and beta () =
    abstract member bar: alpha

然后我得到:

error FS0365: No implementation was given for 'abstract member beta.bar : alpha'

以及我应该添加 AbstractClass 属性的提示

那么如何声明循环定义的抽象类呢?

4

1 回答 1

7

将属性放在“and”关键字之后:

[<AbstractClass>]
type alpha () =
    abstract member foo : beta -> beta

and [<AbstractClass>]  beta () =
    abstract member bar : alpha
于 2012-05-06T05:18:09.770 回答