[erlang-questions] Debug support on for guards?

Henning Diedrich hd2010@REDACTED
Mon May 3 13:53:33 CEST 2010


Thank you for the advice Richard!

The function is to be called often and directly on non-tested data 
coming in over the network.

So at first sight, splitting up seems to bloat things instead of making 
them clearer in this case. There is no moment in time, long up front, 
when the diagnosis should be done. I'll give splitting up a try to learn 
how that looks.

> Why?  What is the programmer supposed to do about it?
> More to the point, what is the *program* supposed to do about it?
1) Discard the data he/it is trying to parse and tell the data source 
that it was no good, and why.

2) If the data was self-generated, e.g. for testing, the programmer to 
use this function may make assumptions that are wrong and the programmer 
to program this function (me) wants a way to inform him in case he runs 
into trouble. By providing more information than function_clause. 
Especially if I can imagine what the wrong assumption may be. As you are 
pointing out, why wouldn't I be allowed to feed negative values in.

[...]
> Why not separate the task into two issues:
> (A) do the main job
> (B) diagnose the problem
> As a general rule, doing this means that someone can call the (B)
> function for some value long before calling the (A) function.
>
> The (A) function can then be streamlined.

Thanks,
Henning


More information about the erlang-questions mailing list