代码之家  ›  专栏  ›  技术社区  ›  Jack

OCAML转发声明

  •  5
  • Jack  · 技术社区  · 15 年前

    有没有一种方法可以在OCAML中执行C样式的前向声明?

    我的问题是,我有两个相互参照的变体:

    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并不是一种广泛使用的编程语言。

    1 回复  |  直到 13 年前
        1
  •  14
  •   Brian    15 年前

    使用

    type T1 = ...
    and T2 = ...
    

    具有递归类型。