<br><br><div class="gmail_quote">On Fri, Dec 5, 2008 at 2:11 PM, mats cronqvist <span dir="ltr"><<a href="mailto:masse@kreditor.se">masse@kreditor.se</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">"Hynek Vychodil" <<a href="mailto:vychodil.hynek@gmail.com">vychodil.hynek@gmail.com</a>> writes:<br>
<br>
> Because:<br>
><br>
> Adding exception raise in this case is typical defensive programming<br>
> and it is not good practice in Erlang except pattern match with<br>
> tagging.<br>
<br>
</div>  so, a function raising an exception when given bad data is not good<br>
  practice in Erlang?</blockquote><div><br>Yes, absolutely. When you don't know what to do, die. see [1] As you wrote below, now you think you know what to do, but in this case just do what to do. Raise different exception is not solution. That's all.<br>
 <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> what gave you that impression? I'd say that the<br>
  opposite is true. "The erlang way", as i was taught it, is to fail<br>
  early and let the supervisor sort it out.<br>
<br>
  also, the way i interpret "defensive programming" is when a function<br>
  continues despite being given bad data. a typical example would be;<br>
<br>
 string:substr("a",2) -> []<br>
<br>
 The fact that<br>
<br>
 string:substr("a",2)<br>
<br>
and<br>
<br>
 string:substr("",2)<br>
<br>
  behaves differently is is just silly. the best would be is they both<br>
  failed with badarg. second best if they both returned [].<br>
<font color="#888888"><br>
  mats</font></blockquote><div><br>You found matter of the problem. But I think both could return empty list.<br></div></div><br>[1] <a href="http://www.sics.se/~joe/thesis/armstrong_thesis_2003.pdf">http://www.sics.se/~joe/thesis/armstrong_thesis_2003.pdf</a><br clear="all">
<br>-- <br>--Hynek (Pichi) Vychodil<br>