<div dir="ltr">Bjorn,<br><br>That would work, too, although it could be considered that libraries that depend on the truncation behavior may in fact unwittingly be harboring truncation bugs, and might be better served by explicitly truncating the integer down to size prior to converting to binary. Perhaps a truncate(Integer, NumBytes) BIF could be provided. Still, being able to turn on range checking for a specific binary conversion (-pragma(range-check), anyone?) or a module might be a very nice compromise feature.<br>
<br>I'll look into what it takes to write an EEP and submit one if I think I can get it right ;-)<br><br>Regards,<br>Ed<br><br><div class="gmail_quote">On Tue, Aug 26, 2008 at 3:24 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"><div class="Ih2E3d">On Tue, Aug 26, 2008 at 8:46 AM, Edwin Fine <span dir="ltr"><<a href="mailto:erlang-questions_efine@usa.net" target="_blank">erlang-questions_efine@usa.net</a>></span> wrote:<br>
</div><div class="gmail_quote"><div class="Ih2E3d"><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">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></div></blockquote>
</div><div>
<br>If checking is turned on for the entire run-time system, library code that depends on the truncation could fail.<br><br>I think it would be better to add optional support in the compiler to turn on checks (either for an entire module, or for individual segments of<br>
a binary).<br><br>If someone writes an EEP, we will consider implementing it.<br><font color="#888888"><br>/Bjorn<br></font></div></div><div class="Ih2E3d">-- <br>Björn Gustavsson, Erlang/OTP, Ericsson AB<br>
</div></div>
</blockquote></div><br><br clear="all"><br>-- <br>For every expert there is an equal and opposite expert - Arthur C. Clarke<br>
</div>