On Thu, Dec 18, 2008 at 4:47 PM, r <nbs.pub...@gmail.com> wrote: > > Is is possible to use some kind of backend storage for Clojure's data > structures? I mean something like Perl's "tie" function that makes > data structures persistent (in sense of storage, not immutability). > > Such storage should be inherently immutable the way Clojure's data are > (so a simple wrapper on sql is probably not good enough) and provide > means of querying database and indexing (ideally multidimensional).
I would looove this. > I wonder if this could be at library level or would rather have to be > hard-coded into Clojure itself. Did anyone try to do it? I've pondered a couple approaches, though only enough to find problems. One approach would work act like a Clojure collection, with structural sharing on-disk. This would be great because it would have multi-versioning and transaction features built right in. It would also have the potential to cache some data in memory while managing reads and writes to disk. But Clojure's persistent collections rely on garbage collection -- when old versions of the collection are no longer referenced, the JVM cleans them up automatically. How would this work on disk? How would you define "no longer referenced"? Another approach would be at the Ref or Agent level, where watchers could be hooked in. (Watchers are currently only for agents, but are planned for refs as well.) Watchers are functions that are called when their underlying mutable object has a change committed, so they'd be able to sync the disk up with new in-memory value. But this means the whole collection would have to be in-memory. Also the watcher gets no hint as to *what* in the collection changed. So for now it seems we'll have to make do with "normal" mechansims like SQL libraries. --Chouser --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---