Compiler bug??

Richard Carlsson richardc@REDACTED
Tue Jul 4 23:47:55 CEST 2006


Anders Nygren wrote:
> 
> foo(X) ->
   if
    X > 1 ->
        ok;       % <- Note semicolon here
        not_ok;
    true ->
        true
   end.

You are being misled by the indentation.
If you write it like this, it's easier to see:

  foo(X) ->
     if
      X > 1 ->
          ok;       % <- Note semicolon here
      not_ok; true ->
          true
     end.

Semicolon within a guard separates disjunctions, i.e.,
it's an "or" operator. It can't be nested, and has
lower precedence than comma ("and").

It would have made a nice submission to the Obfuscated
Erlang Contest, though. :-)

	/Richard



More information about the erlang-questions mailing list