[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: hash-table-{to, from}-alist

From: Ted Zlatanov
Subject: Re: hash-table-{to, from}-alist
Date: Fri, 21 Nov 2008 16:22:59 -0600
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux)

On Fri, 21 Nov 2008 17:02:06 -0500 Stefan Monnier <address@hidden> wrote: 

TZ> I propose the following functions (originals were contributed to Gnus by
TZ> Andreas Fuchs <address@hidden>):

TZ> (defun hash-table-to-alist (hash)
TZ> (defun hash-table-from-alist (alist &rest options)

>> If there are no objections or comments, I'll commit my version tomorrow
>> with a manual update to follow once the functions are stable.  Where
>> should this go under the lisp/ directory?

SM> They don't look too harmful, but I think we need more: we need to hook
SM> this into prin1 and into read so it works transparently.

We can't, because we're converting to an alist and there's no way to
convert back.  True serialization would require a new marker, similar to
() for lists and [] for vectors.  Braces would probably work, I don't
think they are used anywhere:

{ :prop1 prop-value1 :prop2 prop-value2 ... key1 val1 key2 val2 ... }

(:prop1 is :test for example)

WDYT?  It would cause read errors to have an odd number of elements, but
otherwise it's pretty clean.  The properties are the same as those you
can pass to make-hash-table, and are always serialized (but not required
on read).  You can have keys named :test for example, because the :test
property happens first and then any subsequent :test keys are assumed to
be hash keys.

Incidentally, the docs for prin1 should probably have examples for the
output of a vector and a series of simple examples of the other data
types, or a link to somewhere those are shown.  I didn't find it in the

SM> So all this looks pretty "post 23.1" to me.

OK.  If we agree on the format I can produce a patch for eventual


reply via email to

[Prev in Thread] Current Thread [Next in Thread]