【问题标题】:OCaml toplevel not interpreting commentsOCaml 顶层不解释注释
【发布时间】:2012-09-27 17:46:47
【问题描述】:
$ 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
# 

我收到了这个错误

Error: Parse error: illegal begin of top_phrase

当我尝试在解释器中输入评论时。 ocaml 解释器中不允许 cmets 还是我做错了什么?

【问题讨论】:

  • 猜这是因为;; 不在评论范围内
  • 如果 ;; 在注释块内,解释器会期待输入,直到再次以 ;; 终止。

标签: ocaml ocaml-batteries


【解决方案1】:

我会说你什么也没输入,这是一个语法错误。

# (* Hello *) ;;
Error: Syntax error

尝试在评论后输入一些内容:

# (* Hello *) 3 ;;
- : int = 3

【讨论】:

  • 谢谢,这是有道理的。甚至 python 和 ruby​​ 也不允许在他们的 REPL 中使用这样的 cmets。只有 Erlang 和 mono-csharp-shell 允许这样做。所以我想不期待这样的事情是公平的。
猜你喜欢
  • 2020-07-11
  • 1970-01-01
  • 2019-04-09
  • 2015-04-18
  • 2023-04-10
  • 1970-01-01
  • 2022-07-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多