From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.lisp.guile.devel Subject: Growable arrays? Date: Sat, 09 Jun 2012 14:32:28 +0200 Organization: Organization?!? Message-ID: <87hauku0mb.fsf@fencepost.gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1339245178 11792 80.91.229.3 (9 Jun 2012 12:32:58 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 9 Jun 2012 12:32:58 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Jun 09 14:32:57 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SdKqb-0001y9-G4 for guile-devel@m.gmane.org; Sat, 09 Jun 2012 14:32:53 +0200 Original-Received: from localhost ([::1]:59933 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SdKqb-00058a-Bs for guile-devel@m.gmane.org; Sat, 09 Jun 2012 08:32:53 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:55194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SdKqX-00057t-SP for guile-devel@gnu.org; Sat, 09 Jun 2012 08:32:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SdKqW-000757-4x for guile-devel@gnu.org; Sat, 09 Jun 2012 08:32:49 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:46944) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SdKqV-00074o-UG for guile-devel@gnu.org; Sat, 09 Jun 2012 08:32:48 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1SdKqR-0001cj-2P for guile-devel@gnu.org; Sat, 09 Jun 2012 14:32:43 +0200 Original-Received: from p508eba28.dip.t-dialin.net ([80.142.186.40]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 09 Jun 2012 14:32:42 +0200 Original-Received: from dak by p508eba28.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 09 Jun 2012 14:32:42 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 31 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: p508eba28.dip.t-dialin.net X-Face: 2FEFf>]>q>2iw=B6, xrUubRI>pR&Ml9=ao@P@i)L:\urd*t9M~y1^:+Y]'C0~{mAl`oQuAl \!3KEIp?*w`|bL5qr,H)LFO6Q=qx~iH4DN; i"; /yuIsqbLLCh/!U#X[S~(5eZ41to5f%E@'ELIi$t^ Vc\LWP@J5p^rst0+('>Er0=^1{]M9!p?&:\z]|;&=NP3AhB!B_bi^]Pfkw User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux) Cancel-Lock: sha1:+hbfRNrU0kCpd1xHr6j8L0/qWoQ= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:14568 Archived-At: Hi, the main data structure of Lua is a "table", an associative array, and a table t has a continguous numerically addressed part from 1..#t, with all other indices going through a hashing mechanism. One principal distinguishing feature, like with a Scheme hashtable, is the ability to grow on-demand. Scheme/Guile vectors are fixed size. Now I have a situation where I have a basic type lattice with records stored in vectors, and this type lattice may be extended dynamically (which typically happens at the start of a whole file, for potentially multi-file runs). Scheme does not offer a suitable data structure for that. It is a bit of a nuisance that one can grow a hashtable efficiently and on-demand, but not so an array. Now it would be possible when the type lattice gets extended to store the new entries in a hashtable and go from there. Or put them into a list, and reallocate on first access beyond the existing element. That seems rather contorted. And since there is, if I remember, a project to run Lua on top of Guile, having a fundamental and reasonably efficient data structure corresponding to a Lua table, or at least the contiguous part of a Lua table, would seem like a reasonably useful idea. After all, there already _is_ such a mechanism underlying hash tables so it seems somewhat peculiar not to have it available for vectors as well. Suggestions? -- David Kastrup