How do you inspect the type of (*) on OCaml's toplevel?

ⅰ亾dé卋堺 提交于 2019-12-09 03:34:29

问题


I wanted to see the type of the multiplication function (*), so I tapped it into the OCaml toplevel.

# (*)

However, the toplevel echoed:

(*);; 1: this is the start of a comment.

and then consumed any further input I put in. I figured that I had to get out of the comment mode by pressing Ctrl+d to send EOF. Great. But surely, I should be able to query the type of any function, including our mysterious multiplication function (*)?!

I would be incredibly disappointed if that is a limitation of the toplevel.


回答1:


It does recognize *) as the end of the comment, but it's still waiting for the end of the expression. I.e. if you enter two semicolons, it will give you a syntax error and allow you to enter another expression.

To get the function * type ( * );; with spaces to distinguish it from comment symbols.



来源:https://stackoverflow.com/questions/5134718/how-do-you-inspect-the-type-of-on-ocamls-toplevel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!