<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 26 Oct 2017, at 20:31, Jesper Louis Andersen <<a href="mailto:jesper.louis.andersen@gmail.com" class="">jesper.louis.andersen@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">It is generally a bad idea to rely on order in anything which uses a hash function. The hash function is often subject to change---rather quickly I might add if it proves to be a security bug. Picking a family of hashes and seeding it randomly is usually a good trick.<div class=""><br class=""></div><div class="">Our "sister language" Go *randomizes* iteration order on its maps. This is to force programmers into not relying on the map order at all, even if it happens to be ordered right now. This opens up implementations in the future.</div><div class=""><br class=""></div><div class="">If you wanted order in a map, it would be *far* better if you could create a map based on RB-trees or the like. Those are naturally ordered by structure. OCaml, for instance, defines Hash Tables as well as Maps. The latter is the ordered variant.</div><div class=""><br class=""></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Thu, Oct 26, 2017 at 8:07 PM Ulf Wiger <<a href="mailto:ulf@wiger.net" class="">ulf@wiger.net</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto" class=""><div class="">But they *are* ordered. Otherwise, comparison of two maps would be undefined. </div><div dir="auto" class=""><br class=""></div><div dir="auto" class="">BR, </div><div dir="auto" class="">Ulf W</div></div><div dir="auto" class=""><div dir="auto" class=""><br class=""><div class="gmail_extra" dir="auto"><br class=""><div class="gmail_quote">Den 26 okt. 2017 18:20 skrev "Roger Lipscombe" <<a href="mailto:roger@differentpla.net" target="_blank" class="">roger@differentpla.net</a>>:<br type="attribution" class=""><blockquote class="m_-8746558959939451565quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="m_-8746558959939451565quoted-text">On 26 October 2017 at 16:30, Ulf Wiger <<a href="mailto:ulf@wiger.net" target="_blank" class="">ulf@wiger.net</a>> wrote:<br class="">
> Wouldn't it be reasonable to have such a function?<br class="">
<br class="">
</div>First thought: No, because people would start abusing it. Maps *aren't* ordered.<br class="">
</blockquote></div><br class=""></div></div></div>
_______________________________________________<br class="">
erlang-questions mailing list<br class="">
<a href="mailto:erlang-questions@erlang.org" target="_blank" class="">erlang-questions@erlang.org</a><br class="">
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank" class="">http://erlang.org/mailman/listinfo/erlang-questions</a><br class="">
</blockquote></div>
_______________________________________________<br class="">erlang-questions mailing list<br class=""><a href="mailto:erlang-questions@erlang.org" class="">erlang-questions@erlang.org</a><br class="">http://erlang.org/mailman/listinfo/erlang-questions<br class=""></div></blockquote></div><br class=""><div class=""><br class=""></div><div class=""><div class="">I guess if at least `maps:to_list/1` would return the keys in order it would  be already a benefit. </div><div class=""><br class=""></div><div class="">Another usage of such order is when you want to sign the object to compare  with others across the network. I have such usage when I’m using maps as a representation for JSON.</div><div class=""><br class=""></div><div class="">- benoît</div></div></body></html>