Allow MAP! indexing?
The MAP! datatype is a dictionary, providing a hashed access storage method.
Recently, we extended MAP! to allow integers as keys (in addition to words and strings). This is handy to manage sparse arrays.
m: make map! 100
>> print [m/1 m/10 m/500 m/1234567]
== this is an example
Ok, agreed, that kind of thing can be very useful.
However, now we've lost the ability to ever access the map as a series, independent of its key values. We now get:
>> first m
>> pick m 1
>> pick m 2
Is this a desirable result, or did we just lose something?
Note that we can still use the select function to obtain values from keys:
>> select m 1
So, for maps, pick is a synonym for select. They are the same.
But should they be?
There are times when I want to obtain the first value of a MAP! to use as a default value for something. At other times, it would be nice to be able to iterate over the MAP!, even though we are not guaranteed the order of the elements. And, to be safe, we may only allow index by number, not by series offsets (more research is required there.)
Although it is true we can use to-block to return the map as a block, for a simple index access that operation is not efficient.