[Top][All Lists]

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

Re: Growable arrays

From: David Kastrup
Subject: Re: Growable arrays
Date: Thu, 14 Jun 2012 21:35:48 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux)

Daniel Llorens <address@hidden> writes:

> I do not think this is a good idea. Guile arrays are just views of a
> vector. Are you proposing to have a separate array implementation? The
> resize operation clashes with the notion of shared views, and it only
> makes sense for arrays of rank 1. It can defined on the ravel (the old
> C++ library, Blitz++, has it) but I don't quite see how it would work
> in Scheme.
> It's true that arrays are complex. They should be simpler. For
> example, I'd remove the arbitrary lower bound feature. Do people use
> it? I've never used it, and I use arrays all the time.

If you take a look at "Numerical Recipes in C" (unless they got their
act together in a later edition), they just mapped the Fortran code 1:1
to C.  And I mean 1:1 and not 1:0.  They left the 0 index empty.  And
implemented arrays not as "a view" on a vector, but rather as as a
vector of independently allocated vectors.  Of course, all on the heap.

I should think that being able to interchange 0/1 based would be the
most important application.  Then you would want to have this feature
for translating Pascal programs (they are start index agnostic).
Indexes in math often run from 1, being able to translate into a
straightforward 1-based rendition can avoid transliteration errors.

It is definitely a higher-level feature and not a fundamental property
of underlying primitive data types, though.

David Kastrup

reply via email to

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