您如何检查OCaml顶层的(*)类型? [英] How do you inspect the type of (*) on OCaml's toplevel?
问题描述
我想查看乘法函数(*)的类型,所以我将其输入到OCaml顶层.
I wanted to see the type of the multiplication function (*), so I tapped it into the OCaml toplevel.
# (*)
但是,顶层回应:
(*);; 1: this is the start of a comment.
,然后消耗掉我输入的所有其他输入.我发现必须通过按Ctrl+d
发送EOF才能退出注释模式.伟大的.但是可以肯定的是,我应该能够查询任何函数的类型,包括我们神秘的乘法函数(*)
?!
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.
推荐答案
它确实将*)
识别为注释的结尾,但是它仍在等待表达式的结尾. IE.如果输入两个分号,则会出现语法错误,并允许您输入另一个表达式.
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.
这篇关于您如何检查OCaml顶层的(*)类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!