[erlang-questions] Best practice for defining functions with edoc,erlc,eunit and the dialyzer
Wed Dec 2 23:53:14 CET 2009
On Dec 2, 2009, at 11:31 PM, Zoltan Lajos Kis wrote:
> One more thing that can be addressed is the order of exporting (and
> defining) functions. My preference is to:
> - 1, export API functions
> - 2, export Behavior callback functions (a separate export line for
> each behavior)
> - 3, export internal functions. The functions that you _don't want
> to export_, but Erlang makes you to do so in order to use them in
> spawns, applys, etc.
Could I make a plea for
- a SINGLE export list for all "API" (horrible term) functions
- in alphabetic order
> Something like:
> %% API
> -export([start_link/0, update/0, get/1, put/2, ...]).
It's just that much easier to see what the module is all about.
Someone using emacs can easily keep such a list in order using
> %% Behavior callbacks
> -export([init/1, handle_call/3, handle_cast/2, ...]).
Years ago I recommended that the syntax should be extended
so that a cross-checking tool could tell that these functions
were *intended* to be used as callbacks by that behaviour and
weren't just accidentally adjacent.
> %% Internal functions
> -export([spawnee/0, applyee/2, ...]).
Now that we have spawn(fun () -> ... end) and F(...),
we shouldn't need this group at all.
More information about the erlang-questions