<div dir="ltr">Bjorn,<br><br>Thank you for updating the documentation. <br><br>However, I strongly disagree that silently truncating integers in conversion to binaries is a feature. The huge number of bugs in C/C++ programming due to overflows in general, and the creation of secure integer libraries to prevent this, should be a strong indicator of the potential harm in allowing this.<br>
<br>In "Programming Erlang", Joe Armstrong writes:<br><br>"Erlang uses arbitrary-sized integers for performing integer arithmetic. In Erlang, integer arithmetic is exact, so you don't have to worry about arithmetic overflows or not being able to represent an integer in a cer-<br>
tain word size."<br><br>But as soon as you convert to binary, that protection is lost and you <i>do</i> have to worry about integer overflows. Erlang is designed for programming fault-tolerant systems, yet this "feature" actually contributes to potential faults. The compiler and run-time should be there to help us, not hinder us.<br>
<br>How difficult could it be to add <i>optional</i> run-time checking to detect this condition without a serious risk of adverse effects on the correctness of Erlang run-time execution?<br><br><div class="gmail_quote">On Tue, Aug 26, 2008 at 2:18 AM, Bjorn Gustavsson <span dir="ltr"><<a href="mailto:bgustavsson@gmail.com">bgustavsson@gmail.com</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 dir="ltr">2008/8/22 Edwin Fine <span dir="ltr"><<a href="mailto:erlang-questions_efine@usa.net" target="_blank">erlang-questions_efine@usa.net</a>></span><div class="Ih2E3d">
<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div dir="ltr">I refer to the following post. I was caught unawares by this apparently undocumented behavior.<br><br><a href="http://www.erlang.org/pipermail/erlang-questions/2007-July/027657.html" target="_blank">http://www.erlang.org/pipermail/erlang-questions/2007-July/027657.html</a><br>
<br>May I strongly recommend placing this information (taken from the above post) in the Erlang Reference Manual, in the section on binaries. It may save other people time and confusion. A further question is whether or not this <b>should</b> be the behavior. As a language used for writing highly reliable systems, shouldn't this overflow condition be caught? Maybe as an optional run-time flag?<br>
<br><font size="4"></font></div></blockquote></div><br></div>We consider the behavior to be a feature.<br><br>I have now added some information about the behavior to the reference manual (to appear in R12B-4).<br><br>/Bjorn<br clear="all">
<br>-- <br>Björn Gustavsson, Erlang/OTP, Ericsson AB<br>
</div>
</blockquote></div><br><br clear="all"><br>-- <br>For every expert there is an equal and opposite expert - Arthur C. Clarke<br>
</div>