[erlang-questions] When to return {ok, Value} or just the Value

Gianfranco Alongi <>
Mon Nov 14 20:14:16 CET 2011


For all of us that has touched upon Haskell and other white ivory
tower functional languages,
I would strongly encourage the good practice of pure functions which
are also easily testable.

I would not encourage flow control through throws when a returned
value is so much more appropriate.
For those who find themselves writing case-ladders, look into monads
from haskell and draw upon the power of the sequencer idea.

/G


On Mon, Nov 14, 2011 at 7:09 PM, Max Bourinov <> wrote:
> Agree with Max Lapshin. I also use the same approach.
> On Mon, Nov 14, 2011 at 4:23 PM, Max Lapshin <> wrote:
>>
>> I think, it is a very good rule to choose whether function can be
>> tuple-return or throw-return:
>> if it has to work with outside world, than let is return {ok, Value} |
>> {error, Reason}
>> if it is "clean", than return Value or throw error is ok.
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://erlang.org/mailman/listinfo/erlang-questions
>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
>



More information about the erlang-questions mailing list