[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: Mon, 11 Jun 2012 14:36:44 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux)

Daniel Hartwig <address@hidden> writes:

> On 11 June 2012 20:00, David Kastrup <address@hidden> wrote:
>>> I guess to summarize: if you want an abstraction like tables, you would
>>> build it out of vectors and hash tables.  But vectors and hash tables
>>> themselves are the lower-level building blocks.
>> Not low-level enough: they are already specialized in different
>> directions making them equally unsuitable for footing the bill.
> Really?
> The Implementation of Lua 5.0 [1], section 4 illustrates how Lua
> tables are constructed from a standard hash table and array (vector).
> In particular, see Figure 2.


> The contiguous, numerically indexed slots are stored only in the
> array, with all other slots stored only in the hash table.  This is
> perfectly able to be implemented in guile using the standard vectors
> and hash tables.  It does require the vectors to be growable,

Cough, cough.  Standard vectors are not growable.  Which is the original
problem of this thread, never mind Lua.

> a that capability which has already been demonstrated.


> As Andy points out, Scheme (and guile) provide a toolset of primitive
> data types out of which you can build the particular abstractions you
> require.

Too bad that the existing types all have rather arbitrary seeming
limitations.  Vectors don't grow, hashtables have additional indirection
through hash buckets and coalescing lists, vlists are immutable.

It seems like they are all rather similar, and all with a rather
arbitrarily chosen additional restriction tacked on making them
unsuitable for this task.

> When comparing Lua to guile I would not consider it an issue that
> guile does not natively provide a particular data type because most
> data types are simple to implement with the tools provided.

Except that this one isn't.

David Kastrup

reply via email to

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