On 11 June 2012 15:25, David Kastrup <d...@gnu.org> wrote: > Yes, but then it will actually be quite rare that the structure is > extended while it is read rather often. It would probably do fine to > just do the extension lazily by exception, but then wrapping a catch > around every access is likely to be slower than checking the addition > list to be empty.
Certainly, catching exceptions is expensive even for the edge-case of the rare write op. Not sure why you would go that route though I suppose you understand your use case much better :-) For reference, attached is a growable vector I use in several projects, adapted to support the length operation similar to Lua (i.e. first unset numerical index). There is no catching of exceptions here, every access to the data is through the dynvector procedures which check the index and vector size.
dynvector.scm
Description: Binary data