Erlang Coding Standards and Best Practices

My team is studying some Erlang in my new job. We have the code right now, but the code is starting to get a little dirty and incompatible.

I would like to know if there are coding standards followed by the Erlang community and they can be used as a baseline. Things like indentation, assignment of variables and functions, structure of modules, etc.

Also, is there any tool that will check these parameters? I think in PEP8 or PyFlakes in the Python world. I use vim and it will detect syntax errors, which is nice, but I would like to do it a little further and try to maintain a good, consistent style that we can provide and make the code more readable.

UPDATE: About Kemal's comment, I have to say that it is very interesting (and we will make good use of it), but does not fully cover the topic. My problem is to convince the team to use a consistent code style as much as possible. A good way to convince everyone is to use the coding style recommended by the Erlang community. Perhaps this does not exist, but I would like to try as simple things as choosing CameCase over Underscored_words, which can greatly facilitate code understanding and readability.

+6
source share
4 answers

Well, this is http://www.erlang.se/doc/programming_rules.shtml . It is quite comprehensive.

+10
source

. ? :

init([]) ->
   AChild = {'AName',{'AModule',start_link,[]},
         permanent,2000,worker,['AModule']},
   {ok,{{one_for_all,0,1}, [AChild]}}.

:

init([]) ->
   AChild = {
      'AName',
      {'AModule', start_link, []},
      permanent,
      2000,
      worker,
      ['AModule']
   },
   {
      ok, 
      {
         {one_for_all,0,1}, 
         [AChild]
      }
   }.

:

init([]) ->
   AChild = { 'AName'
            , {'AModule', start_link, []}
            , permanent
            , 2000
            , worker
            , ['AModule'] }
   { ok, 
      { {one_for_all,0,1}
      , [AChild] } }.

, . , .

+3

Elvis, , Inaka (), Erlang .

+2

...

erlang-questions ( , , ), ( UUID) , , .

, edoc Erlang:

The problem of creating multi-line lambda declarations in place and other multi-line problems V. S. The use of labels in the source (with comparison in compiled code) is considered here: https://zxq9.com/archives/1337 .

0
source

All Articles