<br><br><div class="gmail_quote">On Wed, Dec 21, 2011 at 8:21 PM, August Schwartzwald <span dir="ltr"><<a href="mailto:august.schwartzwald@gmail.com">august.schwartzwald@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Hi,<br>
<br>
I started to learn Erlang about a month ago. I really like it and think that with some more practice it will become a both unique and powerful tool in my growing box of programming languages. However, there is one thing about it that I find extremely annoying: The line endings.<br>

I currently know 5 programing languages, they have either 0 (python) or 1 way to end lines (usually the ';' character). Erlang totally stands out here and requires that lines are ended in one of 4 different ways.<br>

<br>
Did some googling without finding any good reason to why the language works in this way. Can anyone here explain this?<br></blockquote><div><br>There is no such ting as a "Line" in Erlang. Everything is a "form" so there are no<br>
line ending only form endings. A form is ended by a top-level "dot whitescape".<br><br>Dot is a period "." white space is a blank,tab,newline or comment.<br>Comments start with "%" and are terminated by a newline<br>
<br>Top level means dot-whitespace is not contained inside a string, a quoted atom or a comment.<br><br>The dot-whitespace convention came from Prolog, this is because Erlang was first implemented in Prolog.<br><br>I don't really know why this convention was adopted in Prolog - but it might<br>
have been done to simplify error handling. If you get a parse error in a form<br>the parser wants to recover in some way. In Erlang/Prolog the strategy for error recovery is extremely simple, if you get a parse error in a form the parser just reports the error and goes to the next form - what constitutes a form can be seen easily by only<br>
looking at the stream of tokens generated by the tokeniser. This make recovering<br>from parse errors very simple.<br><br>Dot-whitespace can be viewed as a synchronizing token for the purposes of error<br>recovery during parsing of incorrect forms.<br>
<br>The easiest was to think of a form, is that it's like a sentence in English.<br><br>In your mail which posed this question, you ended  most sentences with<br>dot whitespace (the exception was ? as a terminator), so Erlang forms are just<br>
like English sentences.<br><br>Just like in English semicolons are "long range" operators and separate clauses;<br>whereas commas separate short range constructs.<br><br>Cheers<br><br>/Joe<br><br><br><br><br> </div>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Thanks<br>
______________________________<u></u>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/<u></u>listinfo/erlang-questions</a><br>
</blockquote></div><br>