[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Growable arrays?

From: Daniel Hartwig
Subject: Re: Growable arrays?
Date: Mon, 11 Jun 2012 17:01:45 +0800

On 11 June 2012 15:25, David Kastrup <address@hidden> 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.

Attachment: dynvector.scm
Description: Binary data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]