Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: db module



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.



Messages sorted by: Reverse Date, Date, Thread, Author