[erlang-questions] Wanted additions to the maps module?

ok <>
Mon May 9 14:02:38 CEST 2016


> On Mon, May 9, 2016 at 2:01 AM, Richard A. O'Keefe <>
> wrote:
>
>> I thought maps were *not* intrinsically ordered.
>>
>
> They aren't.
>
> You don't need a defined order in order to iterate using first and next,
> see for example how ets:first/ets:next work on a set.

You *do* need a defined order for iteration to *make sense*.
If the value of maps:first_key(Map) and maps:next_key(Map, Key)
is not *determined* by the *value* of Map (without reference to
the history of how the Map was built or any other inscrutable
properties such as where it happens to be stored), then these
things just aren't functions.

Since we *do* have an ordering on terms, it *would* be possible
to define 'first' as 'least in standard order' and 'next' as
'next smallest in standard order'.

Without some clearly defined history-independent order being
set up for these functions, you can end up with two *equal*
maps being traversed in different orders.

I've been there in the Prolog world and still have the scars.





More information about the erlang-questions mailing list