是否有 OCaml 工具支持使用 Perl 的 Perl::Critic 模块等最佳实践?
是否存在一种工具可以分析 OCaml 程序并提出风格和代码方面的一些改进建议?在 Perl 的世界里仍然存在 Perl::Critic 避免不良风格。
我需要的是一些工具,这些工具不仅可以提示样式,还可以使事情变得更清晰,并避免 OCaml 程序中非尾递归的构造。
有什么提示吗?
Does there exist a tool which analyzes OCaml programs and suggests some improvements in style and code? In the world of perl there still exists Perl::Critic to avoid bad style.
What I need are some tools which make hints not only about style but also to make things cleaner and to avoid constructs which are not tail recursive in OCaml programs.
Any hints?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有使用过它,但上周有关 Caml 群组的消息提到吉祥物。它看起来就是你所追求的。我不确定尾递归标准;上述项目的作者没有提到它们,但提到了插件功能。
或者,使用
-dlinear
(对于ocamlopt[.opt]
)进行编译将生成线性化代码,其中提及该函数是否是尾调用。-annot
也会产生尾部调用信息,但除了 变更日志(在 3.11.0 中添加)。它以什么方式标记尾部调用,它不会做相反的标记非尾部调用(或者也许有办法?)。下面是一个名为sum
的函数的输出示例,它产生(以及更多输出),
但我认为经验将是您最好的选择。查看一些流行的项目(例如电池),了解风格和典型惯例。我不认为插件会帮助您调用累加器变量
acc
或延续cont
。I have not used it but a message on the Caml Groups last week mentions Mascot. It looks to be what you are after. I'm not sure about the tail-recursion criteria; the author of the above project doesn't mention them, but does mention plugin capabilities.
Alternatively, compiling with
-dlinear
(forocamlopt[.opt]
) will produce linearized code that mentions if the function is a tail-call.-annot
also produces tail-call information, but I cannot find a reference aside from the changelog (it was added in 3.11.0). What way it does tag tail-calls, it doesn't do the converse, tag non-tail calls (or maybe there is a way?). Below is an example of the output for a function calledsum
,produces (amongst much more output),
I think experience is going to be your best bet though. Look through some popular projects (Batteries, for example) to get a feel for style and typical conventions. I don't think a plugin is going to help you call your accumulator variables
acc
or continuationscont
.