【发布时间】:2014-02-17 17:05:12
【问题描述】:
我有如下代码语句:
let execute command =
match command with
|Skip -> ()
|Changestate (l,r) -> (let l = ref r)
|_ -> failwith "Not a command"
当我在顶层运行它时,我收到以下错误:
1 let execute command =
2 match command with
3 |Skip -> ()
4 |Changestate (l,r) -> (let l = ref r)
5 |_ -> failwith "Not a command";;
6 Error: Syntax error
语法错误似乎出现在第 4 行末尾的括号中。我希望这行做的是将 l 处的值更改为 r 的引用变量,但不返回实际值。
【问题讨论】:
-
我猜你想要做的是 l := r 但我们不太确定,因为你没有提供命令的类型定义。
-
这正是我想做的。我省略了 def 类型以尽量保持示例简短。谢谢!
标签: syntax ocaml match let imp