Version 16 of tie

Updated 2006-08-25 01:18:48

http://tcllib.sourceforge.net/doc/tie.html


Array persistence. This package provides a framework for the creation of persistent Tcl array variables. It is also generic enough to allow the distribution of the contents of Tcl arrays over multiple threads and processes, i.e. communication. Persistence and communication are accomplished by tying a Tcl array variable to a data source. Examples of data sources are other Tcl arrays and files.

CMcC 20050303 - I've written a Metakit backend for tie

RLH 20050901 - When would this be included in tcllib? With the next 8.4 release?

AK This can go into the example area.


Am I using tie correctly? The following script:

    package require tie
    set a(y) 1
    set a(z) 3
    tie::tie a file a.save
    set a(aa) 2
    set a(ab) 3
    set a(ac) 4

Gives me an error:

    can't set "a(ab)": can't unset "cache": no such variable
        while executing
    "set a(ab) 3"

AK: I can confirm this error. This looks very much like a bug. Please submit this (and any future) bugs to the Tcllib SourceForge project. See http://tcllib.sourceforge.net/ , then follow the links to the "Bug Database" and "Submit New".

VPT I don't think anyone has put a bug report in for this, at least a search in the bug database didn't find "tie". I got it working by putting a catch around the "unset cache" in the Invalidate method in the tie_file.tcl file. This looks like a really useful module but I presume people aren't using it, at least not with files. It seems to me that if you don't use it you have to reinvent it if you want persistance of array data.

AK: There was a bug-report, it is however already been closed, because the problem is fixed in the CVS head. See http://sourceforge.net/tracker/index.php?func=detail&aid=1310038&group_id=12883&atid=112883


JGB: the problem with Tcl's implementation of Tie is that it doesn't let you have massive arrays like Perl does. With Perl's tie() the actual get/set calls in the array implementation are replaced with calls to a dbm-style-db, so that you can program with no regard for the memory use of the array. Array calls turn out to be a very handy way to work with dbm files. Of course, one can emulate this in Tcl by using Berkeley-DB's Tcl library and using it like an array.

Several months later, I discovered that Tgdbm has an "attach" feature which works just like Perl's tie(), namely it works with very large sized arrays http://www.vogel-nest.de/wiki/Main/TgdbmDoc


[ Category Interprocess Communication | Category Package ]