[Top][All Lists]

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

Re: hashtable-print-readable provide point

From: Ted Zlatanov
Subject: Re: hashtable-print-readable provide point
Date: Fri, 28 Aug 2009 05:18:50 -0500
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1.50 (gnu/linux)

On Sat, 08 Aug 2009 15:55:26 -0400 Stefan Monnier <address@hidden> wrote: 

>>> (when (hash-table-p (read-from-string (prin1-to-string (make-hash-table))))
>>> (provide 'hashtable-print-readable))
>> The test doesn't seem to work.  Is the code implemented correctly?

SM> This is email-code, of course: guaranteed 100% untested.

Sorry I didn't respond sooner: read-from-string returns a cons cell, so
(car ...) needs to be called.  subr.el already has the right invocation
in the provide.

On Thu, 06 Aug 2009 18:58:13 +0200 Florian Beck <address@hidden> wrote: 

FB> Ted Zlatanov <address@hidden> writes:

>> I've committed the patch with the usual ChangeLog information.

FB> I was in eager anticipation for this patch, but I can't get it to work
FB> with strings as keys:

FB> (let ((hashtable (make-hash-table :test 'equal)))
FB>   (puthash "key" "value" hashtable)
FB>   (gethash "key" (car (read-from-string (prin1-to-string hashtable)))))

FB>   => nil

Printing screwed up strings on both keys and their associated values.  I
installed a fix; the relevant piece was

          for (i = 0; i < size; i++)
            if (!NILP (HASH_HASH (h, i)))
                if (i) PRINTCHAR (' ');
                print_object (HASH_KEY (h, i), printcharfun, 0);
                PRINTCHAR (' ');
                print_object (HASH_VALUE (h, i), printcharfun, 0);

I should have had the escape flag (third argument) as 1 in order to
escape things correctly.  I tested it and it works for me.  Can you try?


reply via email to

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