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

Artie Gold the.artiegold@REDACTED
Mon May 9 15:43:23 CEST 2016


Old naïvist here...

Why should a defined order be necessary in an immutable context? 

Thanks (and thanks),
--ag

Sent from my iPhone

On May 9, 2016, at 7:02 AM, <ok@REDACTED> <ok@REDACTED> wrote:

>> On Mon, May 9, 2016 at 2:01 AM, Richard A. O'Keefe <ok@REDACTED>
>> 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.
> 
> 
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list