Erlang language issues

Joe Armstrong joe@REDACTED
Mon Apr 22 10:42:41 CEST 2002


<On Fri, 19 Apr 2002, Peter H|gfeldt wrote:

> 
> On Thu, 18 Apr 2002, Robert Virding wrote:
> [...]
> > 
> > That is why I have been against block comments.  If they are so great 
> > why were line comments added to C++?
> 

  To make it even more ugly :-)

> I completely agree. If you want to annotate your documentation with proper
> Erlang module code, you can do as follows :-). 
> 
> -module(nocommentsplease).
> -export([foo/0]).
> 
> -ifdef(BULKYBLOCKCOMMENT).
> 
> <A few pages of documentation goes here>. 
> 
> -endif.
> 
> foo() ->
>     bar.
> 
> /Peter

This, I suppose, is a pessimisation (I'd always wanted to use that word)
of /* and */ :-).

The principle reason for block comments is for the sake of edoc, since if
people write lots of documentation in edoc it will look foul if every
line of documentation is preceded by a %. 

This is not only aesthetically displeasing but also it is a pain to
edit - and yes if you have emacs and the right .el files I'm sure this
can be fixed - but not everybody has emacs (I know they *should* but
they don't).

Why do I think that this is aesthetically displeasing?

Modules consist of code interspersed by comments - or at least I think
they *should* consists of code and comments. If we use a meta
character to distinguish the two (like %) there are two possible
choices


    A) We tag all the comments, leaving the code untagged (this is
       what most languages do.

or

    B) We tag all the code leaving the comments untagged.


Of the two conventions we chose, of course, the wrong one - A) when it
should  have been  B)  -  what we  should  have done  was  to use  the
"literate comment"  convention in Haskell  - we should have  said "all
lines beginning with %" are code - the rest are comments.

The reason  for this is, of  course, comments [which are  in a natural
language] have a far less rigid syntax than code - we *expect* to have
to  write code  according to  rigid syntax  rules (like,  for example,
having to put  a % at the start  of every line) - we do  not expect to
have to  do this for English. At  least, when I went  to school nobody
told me to put a % at the start of every line I wrote - and I guess if
they did this to every line  of text in my daily paper everybody would
start complaining.

So as an alternative to block comments I'd happily consider "literate
Erlang" where the comment convention is reversed.

To quote the Haskell report "The literate style encourages comments by
making them the default" - encouraging comments seems to be a worth
thing to do :-)

Block comments have several advantages, not the least of which is they
save your fingers and are environmentally friendly.

A long time ago Robert changed his login name (and email address etc.)
from robert to rv - this, he ensured me, was to save typing and to
stop him from waring his fingers out - it only took him the best part
of a week to change his name and mail *all* his friends etc. - but
this he assured me was a long term gain. After a mere 47,000 (I forget
the exact number) logins he would reap the benefits and his fingers
would last longer.

    The gain of /* */ over "% per line" comes if you write more than 4
    lines of comments per comment block - we can thus hypothesis that
    those people who write *more* than 4 lines of comments per comment
    block would be in favor of block comments and those who wrote less
    would be against :-)

Why environmentally friendly?

Less characters = less space = smaller disks = less disk factories =
less pollution.

The only *disadvantage* is that you might comment out a large block of
code which you don't easily see when you are editing. What can we do
about that?

	emacs to the rescue [1]

The code bits are color coded (at least mine are) so you can easily
see what's code and whats not -

	/Joe

[1] I know













More information about the erlang-questions mailing list