-
Notifications
You must be signed in to change notification settings - Fork 21
Description
In principle we ought to be able to define all operations on maps and arrays in terms of the primitives defined in the Data Model spec.
Currently the data model defines the primitives as dm:map-entries, dm:array-size, and dm:array-get.
This is a workable set for retrieval functions, though it's not necessarily an ideal set. But what is missing is any primitives for map and array construction.
I think we need to regard the empty array and empty map as given, and then define array:append and map:put as primitives.
Since dm:map-entries() isn't the same as the user-visible map:entries() it might be a good idea to rename it.
Another way of defining the primitives would be to make iteration primitive, so the primitives become
dm:for-each-map-entry($map, fn($key, $value))
and
dm:for-each-array-member($array, fn($position, $value))
This has some merit in that (a) maps and arrays are treated symmetrically, and (b) there are only 2 primitives rather than 3.