[erlang-questions] How do I elegantly check many conditions?

Hynek Vychodil vychodil.hynek@REDACTED
Tue Mar 24 22:58:38 CET 2009


On Tue, Mar 24, 2009 at 10:08 PM, Attila Rajmund Nohl <
attila.r.nohl@REDACTED> wrote:

> 2009/3/24, Hynek Vychodil <vychodil.hynek@REDACTED>:
> [...]
> >
> > code
> >
> > ok = is_new_email1(Email).
> >
> > doesn't looks like same amount of code
> >
> > try is_new_email2(Email) catch throw:email_in_use -> email_in_use end.
> >
> > First one turns return value to exception, second one  turns exception to
> > return value. Second one seems more code, does not?
>
> The beauty of execption handling is that you don't have to handle the
> exception where it was thrown. So in real code the second would be
> something like
>
> checks() ->
>  foo(),
>  is_new_email(Email),
>  bar().
>
> And the catch would be at the call of checks().
>

And again, you assume how I will use your function. It's wrong! You avoid me
to make case when I know what to do.

-- 
--Hynek (Pichi) Vychodil

Analyze your data in minutes. Share your insights instantly. Thrill your
boss.  Be a data hero!
Try Good Data now for free: www.gooddata.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090324/551bd18c/attachment.htm>


More information about the erlang-questions mailing list