From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2310 invoked from network); 30 Sep 2002 15:02:52 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 30 Sep 2002 15:02:52 -0000 Received: (qmail 17692 invoked by alias); 30 Sep 2002 15:02:42 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 17745 Received: (qmail 17678 invoked from network); 30 Sep 2002 15:02:41 -0000 X-VirusChecked: Checked From: Oliver Kiddle To: Zsh workers Subject: Re: db module MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3904.1033396744.1@logica.com> Date: Mon, 30 Sep 2002 15:39:52 +0100 Sender: kiddleo@logica.com Message-Id: On Thu, 12 Sep 2002, Clint wrote: > This allows one to "tie" a Berkeley DB to an associative array (or is > that the other way around?) > > I'm using two hacks. The 'extradata' field in struct hashtable holds the > db handle for that assoc array. Unfortunately, this doesn't seem to be > available from the set and unset functions for the individual elements, > so I had to use a static variable. That means that the last DB to be > opened is the only one that be modified. How can this be handled > sanely? Instead of using pm->u.str to store a string value, I think you could use the u.data field to point to that db handle and then use your own function instead of strgetfn(). However, this is the sort of thing I'm trying to address with the replacement parameter code. I dug it out and made some progress over the weekend. > Other notes: > > This adds yet another library to be linked against all the modules. How hard would it be to modify 16845 as suggested in 16878 so that we at least have a short term solution. > Examples: > > zdb_open -c things /tmp/newdb.db I would use -A instead because it is what we tend to use for associations and we might plausibly tie a database to other types in the future. It's a nice idea. Could be an interesting way to do completion caching. Thinking of it from the perspective of cached variables, it is actually quite similar to mapfile. The mapfile module could easily have been implemented with a builtin. e.g: zmapfile -c file /tmp/file where $file would then be a scalar. And this might go on further with other similar modules. This makes me think that perhaps we could add a hook to typeset so all these things can be declared something like this: e.g: typeset -A things -S db -f /tmp/newdb typeset string -S mapfile -f /tmp/file Oliver This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.