ocaml + oasis +自定义模块,如何编译

时间:2016-10-29 14:18:24

标签: ocaml oasis

所以我有以下文件:

_oasis:

type player =
    {
        name: string;
        score: int;
    }

class player_manager =
    object (self)
        val mutable player_list = ( [] : player list)
        method add p =
            player_list <- p :: player_list
    end;;

main.ml:

ocaml setup.ml -build 
/home/araxia/.opam/system/bin/ocamlfind ocamldep -modules src/main.ml > src/main.ml.depends
+ /home/araxia/.opam/system/bin/ocamlfind ocamldep -modules src/main.ml > src/main.ml.depends
File "src/main.ml", line 4, characters 32-32:
Error: Syntax error
Command exited with code 2.
E: Failure("Command ''/usr/bin/ocamlbuild' src/main.byte -tag debug' terminated with error code 10")
make: *** [build] Error 1
Makefile:7: recipe for target 'build' failed

players.ml:

{{1}}

当我运行make时我得到这个错误:

{{1}}

我是ocaml和oasis的新手,等我做错了什么?

1 个答案:

答案 0 :(得分:3)

这与Oasis没有任何关系,只是在你写作时

let () =
  let mgr = new player_manager

OCaml需要一个in关键字,因为let引入了一个全局变量,它引入了一个局部变量,然后你需要let var = expr in expr,而不是其他任何东西。

所以,用

替换它
let () =
  let mgr = new player_manager in ()

目前因为您没有使用mgr做任何事情。