[erlang-questions] erlang sucks

Sean Hinde sean.hinde@REDACTED
Wed Mar 12 19:30:26 CET 2008

On 12 Mar 2008, at 17:29, attila.rajmund.nohl@REDACTED wrote:

> On Tue, 11 Mar 2008, Sean Hinde wrote:
> [...]
>> The more normal Erlang way to write the equivalent of the C version  
>> would be
>> simply:
>> some_function(X,Y,Z) ->
>>  case handle_some_function(X,Y,Z) of
>>      ok -> ok;
>>      error1 -> handle_error1();
>>      error2 -> handle_error2()
>>  end.
>> I'd argue that it is even more readable than the C version. And not  
>> an 'if'
>> in sight :-)
> But you have to write nonsense like:
>        ok -> ok;

You seem to be mostly complaining about the fact that case .. end and  
if .. end do not have an implicit pass through when no clauses match.

Well, Erlang is not C.

Idiomatic Elang does not mean writing everything in single function  
with a few hundred lines of ifs and gotos. I've read many C programs  
in that style, and also seen Erlang  code attempting to follow the  
same style. It makes for ugly and hard to debug Erlang code. I've no  
idea if it is good C coding style.

In Erlang you have the choice to throw a runtime exception if no  
clause matches, or to provide an explicit wildcard case. The Erlang  
"crash early" philosophy means that in most cases wildcard is the  
wrong solution.


> 				Bye,NAR
> -- 
> "Beware of bugs in the above code; I have only proved it correct, not
>  tried it."
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list