2013-12-23 3 views
1
namespace Test 

type Foo() = 
    member this.HelloFoo = "Foo" 
    member this.HelloFooBar = 
     let b = new Bar() // Why is Bar not visible here? 
     this.HelloFoo + b.HelloBar 
type Bar() = 
    member this.HelloBar = "Bar" 

바가 Foo에서 보이지 않는 이유는 무엇입니까?네임 스페이스의 클래스 가시성

답변

7

F # 선언은 위에서 아래로 처리되므로 에서 참조되는 지점에서 Bar이 정의되지 않았습니다. Bar의 정의를 Foo 위로 이동해야합니다.

유형이 상호 의존적 인 경우 and을 사용하여 둘 다 선언 할 수 있습니다.

type Foo = 
... 
and Bar = 
... 
관련 문제