5
有没有办法在OCaml中做C风格的前向声明?OCaml前向声明
我的问题是,我有两个变体互相称对方:
type path_formula =
[ `Next of state_formula
| `Until of (state_formula * state_formula)
| `UntilB of (state_formula * int * state_formula)
]
type state_formula =
[ `True | `False
| `Not of state_formula
| `And of (state_formula * state_formula)
| `Or of (state_formula * state_formula)
| `Imply of (state_formula * state_formula)
| `Label of string
| `Prob` of (boundf * path_formula)
| `Expc` of (boundi * formula)
]
所以这两个类型必须知道对方的..我搜索了它在谷歌可惜OCaml的是不是这么宽次使用的编程语言..
谢谢,我通常在发现语言特征方面没有问题,但OCaml与我迄今为止所研究的完全不同,而且我只能找到几百页的“phat”参考文献,这些参考文献会让我失去方向:) – Jack 2010-06-11 21:10:13
请注意,您可以掷骰子并搜索F#语法/文档以了解OCaml。核心语法是相同的,所以例如http://stackoverflow.com/questions/1378575/f-forward-type-declarations是一个胜利。 – Brian 2010-06-11 21:37:35
这是一个很好的观点。我不得不选择OCaml,因为他们强迫我。我认为这是一种古老而强大的语言,但如果现代的功能语言(Scala,F#)保持相同的语法,那么这将成为一个不错的选择:) – Jack 2010-06-12 00:48:37