ok or true? (fwd)

Thomas Lindgren thomasl_erlang@REDACTED
Mon Feb 23 12:33:50 CET 2004

--- Joe Armstrong <joe@REDACTED> wrote:
> Things that return two possible atoms should
> *always* return true | false.

What if the function has side effects?

> In general you should stick to regular return values
> like
> 	{ok, Val} | {error, Why}
> 	{value, V} | error
> for the same reason

Case in point:

   lists:keysearch -> {value,X} | false

Argh. Oh well, one can always wrap such madness.

Come to think of it, this raises a question: why do
the standard libraries not make more use of

For instance, instead of returning {ok, Val} or
{error, Why}, one can return Val or exit(Why). There
are numerous advantages: the code is shorter, the
program is more efficient and if you need to return
{ok,Val} or {error, Why}, write a catch-wrapper.


Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.

More information about the erlang-questions mailing list