ocaml + oasis + 自定义模块,如何编译
ocaml + oasis + custom module, how to compile
所以我有以下文件:
_绿洲:
OASISFormat: 0.4
Name: PongBattleServer
Version: 0.1.0
Synopsis: Server for handling multi-player pong games
Authors: Jason Miesionczek
License: MIT
Plugins: META (0.4), DevFiles (0.4)
Executable pongserver
Path: src
BuildTools: ocamlbuild
MainIs: main.ml
main.ml:
open Players;;
let () =
let mgr = new player_manager
players.ml:
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;;
当我 运行 让我得到这个错误:
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
我是 ocaml 和 oasis 等方面的新手。我做错了什么?
这与 Oasis 无关,只是当你写
let () =
let mgr = new player_manager
OCaml 需要一个 in
关键字,因为要么 let
引入一个全局变量,要么引入一个局部变量,然后你需要一个 let var = expr in expr
,没有别的。
因此,将其替换为
let () =
let mgr = new player_manager in ()
暂时,因为您没有对 mgr
做任何事情。
所以我有以下文件:
_绿洲:
OASISFormat: 0.4
Name: PongBattleServer
Version: 0.1.0
Synopsis: Server for handling multi-player pong games
Authors: Jason Miesionczek
License: MIT
Plugins: META (0.4), DevFiles (0.4)
Executable pongserver
Path: src
BuildTools: ocamlbuild
MainIs: main.ml
main.ml:
open Players;;
let () =
let mgr = new player_manager
players.ml:
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;;
当我 运行 让我得到这个错误:
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
我是 ocaml 和 oasis 等方面的新手。我做错了什么?
这与 Oasis 无关,只是当你写
let () =
let mgr = new player_manager
OCaml 需要一个 in
关键字,因为要么 let
引入一个全局变量,要么引入一个局部变量,然后你需要一个 let var = expr in expr
,没有别的。
因此,将其替换为
let () =
let mgr = new player_manager in ()
暂时,因为您没有对 mgr
做任何事情。