Context:
Erlang programs running on heterogeneous nodes, retrieving and storing data from Mnesia databases. These database entries are meant to be used for a long time (e.g. across multiple Erlang version releases) remains in the form of Erlang objects (i.e. no serialization). Among the information stored, there are currently two uses for arrays:
Large (up to 16384 elements) arrays. Fast access to an element using its index was the basis for choosing this type of collection. Once the array has been created, the elements are never modified.
Small (up to 64 elements) arrays. Accesses are mostly done using indices, but there are also some iterations (foldl/foldr). Both reading and replacement of the elements is done frequently. The size of the collection remains constant.
Problem:
Erlang's documentation on arrays states that "The representation is not documented and is subject to change without notice." Clearly, arrays should not be used in my context: database entries containing arrays may be interpreted differently depending on the node executing the program and unannounced changes to how arrays are implemented would make them unusable.
I have noticed that Erlang features "ordsets"/"orddict" to address a similar issue with "sets"/"dict", and am thus looking for the "array" equivalent. Do you know of any? If none exists, my strategy is likely going to be using lists of lists to replace my large arrays, and orddict (with the index as key) to replace the smaller ones. Is there a better solution?