erlang中的静态类型检查 [英] Static typechecking in erlang

查看:111
本文介绍了erlang中的静态类型检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我慢慢爱上了Erlang,只有一个大的大问题。

I'm slowly falling in love with Erlang, and only have one big, BIG problem.

我是Standart ML和ocaml等语言的忠实粉丝具有强大的静态类型检查功能。

I'm a big fan of languages like Standart ML and ocaml with their strong static typechecking.

有没有一种很好的方法来在erlang中引入某种静态类型检查功能。我正在查看类型 -spec 批注。

is there a nice and clean way to introduce somesort of static typechecking in erlang. I'm looking at the -type and -spec annotations.

有人有不错的解决方案吗?

Does anyone have a nice solution?

推荐答案

我有到过那里!我喜欢OCaml和Erlang并定期使用它们。

I've been there! I love both OCaml and Erlang and use them regularly.

当我开始使用Erlang时,我对OCaml已有多年的经验。我花了几周的时间来适应编译器中没有静态类型检查器的事实。但是在那之后,这种痛苦就完全消失了。

By the time I started using Erlang I had years of experience with OCaml. It took me several weeks to adjust to the fact that there's no static typechecker in the compiler. But after that, the pain was completely gone.

在一定程度上,没有类型检查器是值得的。对我来说,这是启发性的经验,确实使我成为了一个更好的程序员。

To a certain extent, going without the typechecker is a worthwhile exercise. For me, it was enlightening experience and really made me a better programmer.

但是,有一个用于Erlang的外部静态类型检查器,称为拨号器。我觉得这很有用。它的问题是您需要单独调用它,并且 slow 。偶尔运行一次(例如在提交代码之前或作为自动化构建的一部分)运行效果很好。我从来没有尝试过在每次编译后运行它,因为要等到它完成会太分心。

There's is, however, an external static typechecker for Erlang called Dializer. I find it very useful. The problem with it is that you need to call it separately and it is slow. Running it once in a while (e.g. before committing code or as a part automated builds) works great. I've never tried running it after each compilation as it would be too much of a distraction to wait until it completes.

这篇关于erlang中的静态类型检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆