[erlang-questions] Best practice for defining functions with edoc,erlc,eunit and the dialyzer

Richard O'Keefe <>
Mon Dec 7 02:48:14 CET 2009


On Dec 5, 2009, at 6:57 AM, Hynek Vychodil wrote:

> I can't believe you forgot one most important think about internal
> exports, It is mandatory for hot code swapping.

You're right, I not only didn't _mention_ that use of internal exports,
I didn't _think_ of it.  The reason is that I was only really thinking
about the internal exports that *shouldn't* be there any more, which is
most of them.

Strictly speaking, in hot code swapping these aren't really _internal_
exports: they are there to let the old version of a module call the
new version, so they are really about calls between two different
modules.  But that's quibbling.

I've just added another style check to my Smalltalk compiler.  I've
actually found such things more helpful in finding bugs than type
checking would have been.  So this got me thinking about a style check
here:

     If a module is likely to contain a long-running computation,
     it SHOULD have a call through ?MODULE:loop(...) somewhere.

What exactly should a style check like this look like?

One thing that occurs to me is that if you have
  - a recursive function
  - in which at least one recursive call is ?MODULE:...
  - then every recursive call should probably use the ?MODULE: prefix
  - and the recursive calls should be tail calls.



More information about the erlang-questions mailing list