我想在OCaml中定義一個接受列表元組作爲參數的異常。但是,這種情況不起作用?以元組爲參數定義異常
# exception Foo of string list * string list;;
exception Foo of string list * string list
# let bar = (["a"], ["b"; "c"; "d"]);;
val bar : string list * string list = (["a"], ["b"; "c"; "d"])
# raise(Foo bar);;
Error: The constructor Foo expects 2 argument(s),
but is applied here to 1 argument(s)
但是,如果我這樣做,它的工作原理
# raise (Foo (["a"], ["b"; "c"; "d"]));;
Exception: Foo (["a"], ["b"; "c"; "d"]).
這是怎麼回事?謝謝!
哇!感謝冗長的解釋!你對OCaml的理解使你看起來像來自INRIA – axsuul 2010-10-15 09:05:34