Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is there no multi-line commenting support in Erlang?

After googling a bit it seems there is no multi-line comment support in Erlang, is this really the case?

And if so, why?

I know some editors support commenting out regions (adding % first on every line of the region) but i don't really want to pick editor based on this.

like image 530
Martin G Avatar asked Aug 15 '14 06:08

Martin G


2 Answers

It's simple. Use preprocessor:

-ifdef(comment).
  Something to comment
  You can add text or
  function(Declaration) ->
     ...
  Which will removed from file
-endif.
like image 185
17 revs, 13 users 59% Avatar answered Nov 09 '22 13:11

17 revs, 13 users 59%


There are no multi-line comments in Erlang.

In general, I haven't found this to be a big deal: I use templates for gen_server and supervisor and a general template for other modules, and all of these include the boilerplate top doc blocks. I get some template support from my editor (Emacs) but you could be editor-agnostic and just write some templates and copy them to any new modules you want.

The biggest use of multi-line comments other than documentation is to comment-out a big chunk of code. Since your Erlang code should generally be small functions, you can just comment out the function call, which is a one-line comment.

like image 45
Nathaniel Waisbrot Avatar answered Nov 09 '22 14:11

Nathaniel Waisbrot