2016-10-29 2 views
0

그래서 나는 다음과 같은 파일이 있습니다OCaml의 + 오아시스 + 사용자 정의 모듈, 어떻게 컴파일

_oasis :

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 등을 처음 사용합니다. 무엇이 잘못 되었나요?

답변

3

이것은 당신이 중 하나를 let 전역 변수를 소개 중 하나가 로컬 변수를 소개하고 당신이 필요로하는 것이기 때문에

let() = 
    let mgr = new player_manager 

OCaml의이 in 키워드를 기대 쓸 때 그것은 단지, 오아시스 또는 무엇이든지 할 수 없다 let var = expr in expr, 그 밖의 것은 없습니다. 당신이 mgr으로 아무것도하지 않기 때문에

그래서, 지금

let() = 
    let mgr = new player_manager in() 

로 교체하십시오.