[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 20:20:01 +0800

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.


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, 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.  This has the advantage that you can optimize heavily for
your own particular needs, is that possible to the same extent with
Lua given that it only has tables as a fundamental container?

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.


reply via email to

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