Lisp HUG Maillist Archive

CL Question printing hash-tables

Hello

this is actually not a LW question.

How do I "print" a hash-table? With all it's content for saving to a file?

Thanks

Guenther



Re: CL Question printing hash-tables

On Fri, 14 Nov 2003 22:27:17 +0000, Guenther Schmidt <gue.schmidt@web.de> wrote:

> How do I "print" a hash-table? With all it's content for saving to a
> file?

There's no portable way to do this. You can of course invent your own
read syntax and a way to print the hash table that way using LOOP or
MAPHASH but IIRC you are not allowed to write a method for
PRINT-OBJECT for hash tables.

Also, you should note that even if you have a way to print a hash
table that doesn't mean you can (readably) print all of its keys and
values.

HTH,
Edi.


Re: CL Question printing hash-tables

* Guenther Schmidt wrote:
> It seems that CL is really a great language, but it shares one 
> shortcoming with many other languages: persistency!!

I think the problem is that persistency is a huge problem if you want
to do it in a way that is at all general (so: a way that is suitable
for incorporation in a language spec).  To do it generally you need to
address issues like equality and perhaps distributed GC which are just
nontrivial.

There are documents on things like equality and object-cloning which
explain why this is so hard.

Fortunately most applications don't actually need completely general
solutions, and CL provides tools which are more than adequate for
dumping & restoring almost arbitrary objects, where you get to control
how it works.

--tim


Re: CL Question printing hash-tables

Guenther Schmidt writes:
 > Thanks Edi,
 > 
 > I suppose that means using hash-tables for "persistent" data is a bad 
 > idea then.
 > 

You can mimic this effect several ways using a database;
 * using CommonSQL, it's easy to create a
   "persistent hash table" construct based on a simple
   table which just looks up values from keys

 * you could use something like Paul Foley's interface
   to berkeley-db, which is even faster and more seamless

 * need to remember that no mechanism can guess how to
   serialize your keys and values, so you still have that
   problem.

Cheers,


Updated at: 2020-12-10 08:58 UTC