A data structure for more efficient runtime support of truly functional arrays
MELISSA E. O'NEILL · Summit (Simon Fraser University) · 1994
Functional languages often neglect the array construct because it is hard to implement nicely in a functional language. When it is considered, it is usually from the context of converting imperative algorithms into functional programs, rather than from a truly functional perspective. In an imperative language, changes to an array are done by modifying array elements, destroying their original values. Unless special measures are taken to support destructive update, an array update in a functional language must produce a new array, without destroying the old one. Since most other functional data structures do not support destructive update, it would be desirable not to have to make a special case of arrays, especially since many kinds of algorithms (backtracking algorithms being a simple example) may find having multiple versions of a data-structure useful. Our goal is to be able to provide a functional array interface where array operations are reasonably cheap. We will look existing techniques that have been used in the past to address this problem area, and then present a new runtime technique that offers very good all-round performance, and can be used where other array mechanisms fail.