[erlang-questions] guards when using dialyzer

9 views
Skip to first unread message

Joel Reymont

unread,
Dec 20, 2011, 10:31:53 AM12/20/11
to erlang-q...@erlang.org
Assuming you are an active user of Dialyzer, do you find yourself using function guards more or less?

I'm wondering if it makes sense to lean heavily on guards when Dialyzer will catch possible issues.

---
Hardcore embedded Linux development
http://www.linkedin.com/in/joelreymont
Device drivers, firmware and debugging


_______________________________________________
erlang-questions mailing list
erlang-q...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

Zabrane Mickael

unread,
Dec 23, 2011, 9:18:20 AM12/23/11
to Joel Reymont, erlang-q...@erlang.org
Could someone advise on that (see below) please?
What are the best pratices?

Thanks.

Regards,
Zabrane

Loïc Hoguin

unread,
Dec 23, 2011, 10:32:26 AM12/23/11
to Joel Reymont, erlang-q...@erlang.org
Guards help Dialyzer because Dialyzer can see whether the call will
succeed more easily than without. For example, if you receive a message
{msg, Variable}, Dialyzer will think Variable is of type any(). It is
because you then add a guard that Dialyzer is able to know whether
Variable is an integer() or something else, and then can pinpoint errors
more precisely.

Another important thing is that guards let you crash sooner, which is
generally what you want, crash at the remote ends of the system, not in
the core.


--
Loïc Hoguin
Dev:Extend

Reply all
Reply to author
Forward
0 new messages