Reputation: 28212
Consider the two abstract classes alpha and beta:
[<AbstractClass>]
type alpha () =
abstract member foo: beta->beta
[<AbstractClass>]
and beta () = //***
abstract member bar: alpha
If I try to compile that I get an error, on the line indicated with * * *:
error FS0010: Unexpected keyword 'and' in interaction
And if I write:
[<AbstractClass>]
type alpha () =
abstract member foo: beta->beta
and beta () =
abstract member bar: alpha
then I get:
error FS0365: No implementation was given for 'abstract member beta.bar : alpha'
and the hint that I should add the AbstractClass Attribute
So how do i declare circularly defined abstract classes?
Upvotes: 5
Views: 179
Reputation: 118865
Put the attribute after the 'and' keyword:
[<AbstractClass>]
type alpha () =
abstract member foo : beta -> beta
and [<AbstractClass>] beta () =
abstract member bar : alpha
Upvotes: 7