<html><head></head><body>Every additional check further reduces performance and some of us are concerned about it.<br><br>If you need correctness checks try to use static analysis tools like dialyzer/gradualizer, that way you catch the bug, we don't have reduced performance.<br><br><div class="gmail_quote">On 16 September 2019 4:02:25 am AEST, Karlo Kuna <kuna.prime@gmail.com> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div dir="ltr">Michal, <div>i really prefer crashing than garbage in, garbage out policy. </div><div>also it would be nice if someone from OTP team confirms if stdlib has "garbage in garbage out" policy. i can certainly see benefits of it but in this case fix is easy and small.  </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Sep 15, 2019 at 7:54 PM Michał Muskała <<a href="mailto:michal@muskala.eu">michal@muskala.eu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">



<div>
<div name="messageBodySection">
<div dir="auto">My understanding is that for most functions in the Erlang standard library, if you don't uphold the contract the documentation specifies the function can crash, but it could also return whatever - in short "garbage in, garbage out" applies.</div>
</div>
<div name="messageSignatureSection"><br>
<div dir="auto">Michał.</div>
</div>
<div name="messageReplySection">On 15 Sep 2019, 18:45 +0100, Karlo Kuna <<a href="mailto:kuna.prime@gmail.com" target="_blank">kuna.prime@gmail.com</a>>, wrote:<br>
<blockquote type="cite" class="gmail-m_-1695047812462014610spark_quote" style="margin:5px;padding-left:10px;border-left:thin solid rgb(26,188,156)">
<div dir="ltr">
<div>Hello,<br></div>
<div><br></div>
<div>i have found surprising  behavior of function lists:append/1: </div>
<div><br></div>
<div>spec and documentation  are in a agreement that this function should accept lists of lists ( [List] ) , </div>
<div>and return list of T ( [T] ), however when we use function like: </div>
<div> </div>
<div>     lists:append([a]) %wrong input parameter </div>
<div>one gets: </div>
<div>     a  % wrong type of a return </div>
<div><br></div>
<div>implementation assumes correct type: </div>
<div><br></div>
<div>append([E]) -> E; % E is not checked for type <br>
append([H|T]) -> H ++ append(T);<br>
append([]) -> [].<br></div>
<div><br></div>
<div>simple solution could be: <br>
<br>
lists:append([E]) when is_list(E) -> E <br>
<br></div>
<div>am i missing something? </div>
<div><br></div>
</div>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br></blockquote>
</div>
</div>

</blockquote></div>
</blockquote></div><br>-- <br>Kind regards,<br>Dmitry Belyaev</body></html>