[erlang-questions] map elements in defined order

Ulf Wiger ulf@REDACTED
Fri Oct 27 15:28:16 CEST 2017


2017-10-27 12:56 GMT+02:00 zxq9 <zxq9@REDACTED>:

>
> I can't believe we are having this discussion. Again.
>

I will admit that I haven't been following the list that closely recently,
but I wasn't aware that this discussion has been had before.



> Having a discussion about internal ordering in the context of efficient
> matches and comparisons *in implementation*: totally logical
>
> Relying on that implementation detail to leak out: ridiculous
>

Again, quoting from the EEP:

«The underlying structure does not need to be sorted, an order could be
produced when needed»

I think that among those who fully accepted the maps API returning elements
in arbitrary order, most would have assumed that
lists:sort(maps:to_list(M)) would do the trick (and, according to the EEP,
it would), and were perfectly content with that.

What I brought up was the (admittedly subtle) point that even if you WANTED
to settle for that, it actually doesn't produce the sort order that applies
to maps internally, and there is no function, anywhere, that will give you
that result - even one where the docs are riddled with warnings about its
inefficiency.


> This discussion comes up a little more frequently than once a year and
> every time it reminds me of watching distributed systems engineers (try
> desperately to) explain CAP theorem tradeoffs to a VP of marketing.
>

Am I the VP of marketing in this story?

BR,
Ulf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20171027/02ba9bfe/attachment.htm>


More information about the erlang-questions mailing list