开发者

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

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 topl开发者_运维技巧evel.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜