OCaml顶级不解释注释
我得到了这个错误OCaml顶级不解释注释,ocaml,ocaml-batteries,Ocaml,Ocaml Batteries,我得到了这个错误 $ ocaml Objective Caml version 3.12.1 _________________________ [| + | | Batteries - | |_____|_|_________________| _________________________ | - Type '#help;;' | | + |] |___________________|_|___| Loading syntax exten
$ ocaml
Objective Caml version 3.12.1
_________________________
[| + | | Batteries - |
|_____|_|_________________|
_________________________
| - Type '#help;;' | | + |]
|___________________|_|___|
Loading syntax extensions...
Camlp4 Parsing version 3.12.1
# (* i am just a comment. nobody cares about me. oh wait! *);;
# Error: Parse error: illegal begin of top_phrase
#
当我试图在解释器中输入注释时。ocaml解释器中不允许使用注释,还是我做错了什么?我认为您根本没有输入任何内容,这是一个语法错误
Error: Parse error: illegal begin of top_phrase
尝试在注释后输入以下内容:
# (* Hello *) ;;
Error: Syntax error
我猜这是因为
如果;,则code>在注释之外代码>位于注释块内,解释器将期望输入,直到再次以;终止代码>。谢谢,这很有意义。即使是python和ruby也不允许在其repl中出现这样的注释。只有Erlang和mono csharp shell允许这样做。所以我想,不期望发生这样的事情是公平的。
# (* Hello *) 3 ;;
- : int = 3