[erlang-questions] Why Erlang compiler don't check functions in module?

Brujo Benavides fernando.benavides@REDACTED
Fri Feb 10 13:48:34 CET 2017


Hi HowId,

	There is a reason why the compiler can’t tell you that erlang:spwan/1 is not defined.
	Fully qualified function calls are bound (I’m not sure if that’s the right word) in runtime.
	That way you can have ghost functions <https://medium.com/erlang-battleground/the-laziest-erlang-git-user-ever-ff69d86cf3c1#.oofph855h> or use meck <http://eproxus.github.io/meck/> and many other goodies.
	That said, there are tools in OTP that would help you find those issues.
	To achieve precisely what you are asking for, you have xref <http://erlang.org/doc/apps/tools/xref_chapter.html> (and if it seem to complex for you, don’t panic… you can always use xrefr <https://hex.pm/packages/xref_runner>).
	But if you want to catch many other kinds of errors (not just typos in function names) you can should use dialyzer <http://erlang.org/doc/apps/dialyzer/dialyzer_chapter.html>.
	And one last thing, if you want those check to happen automatically (which is something truly desirable), you can include the meta suite from katana-test <https://hex.pm/packages/katana_test> in your common test suites.
	Hope this helps :)

> On Feb 10, 2017, at 07:21, Howld <10z98@REDACTED> wrote:
> 
> Dear Developers:
>      As a new developer, the result of the compile I hope is clear to indicate the functions in module if exist when I use compiler cmd like "erlc test.erl". But hopeless, if I write code like "elang:spwan(fun test:foo/0)" in erl file, it happens nothing even warning. I think it increases uncertainty with non-English speaking countrie's developers. And if you think so, I will shame on you. What I real want to express is you should have an idea and there is a long way to improve compiler.
> 
> Best blessing!
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170210/0514713a/attachment.htm>


More information about the erlang-questions mailing list