From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Valentin Baciu Newsgroups: gmane.emacs.help Subject: Re: error "Odd number of elements in hashtable data Date: Thu, 12 Jan 2012 10:55:30 +0200 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1326358551 21086 80.91.229.12 (12 Jan 2012 08:55:51 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 12 Jan 2012 08:55:51 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: ishi soichi Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jan 12 09:55:46 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RlGRm-0003cg-07 for geh-help-gnu-emacs@m.gmane.org; Thu, 12 Jan 2012 09:55:46 +0100 Original-Received: from localhost ([::1]:54258 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlGRl-0005Hm-K7 for geh-help-gnu-emacs@m.gmane.org; Thu, 12 Jan 2012 03:55:45 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:45504) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlGRe-0005HB-E0 for help-gnu-emacs@gnu.org; Thu, 12 Jan 2012 03:55:42 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RlGRY-00052D-HQ for help-gnu-emacs@gnu.org; Thu, 12 Jan 2012 03:55:38 -0500 Original-Received: from mail-vx0-f169.google.com ([209.85.220.169]:60601) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlGRY-000529-C8 for help-gnu-emacs@gnu.org; Thu, 12 Jan 2012 03:55:32 -0500 Original-Received: by vcge1 with SMTP id e1so1392139vcg.0 for ; Thu, 12 Jan 2012 00:55:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syntactic.org; s=syntacticorg; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=57IWkLa6Ab6NLrWNiLa/HZLrkiCIv8BCK1pGyhWLEsI=; b=FDyB7y3pssM3YPkvH/kMQ/c1MY/FfWOpgjp0hpmDc3BeJxHEslJWPAwnt3eMnFjvv5 96w0lr/s1svgyWfqFe3L8cZphgEa8CRmtafAm5rwLjUb6Wgp5TMDSnOVA6495YHBQ/bL /RMDriRQ5wuOwotb1p6zcxYSU5yxelqPSov8U= Original-Received: by 10.220.156.72 with SMTP id v8mr1498359vcw.45.1326358530778; Thu, 12 Jan 2012 00:55:30 -0800 (PST) Original-Received: by 10.52.158.4 with HTTP; Thu, 12 Jan 2012 00:55:30 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.220.169 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:83473 Archived-At: On Thu, Jan 12, 2012 at 4:50 AM, ishi soichi wrote: > I'm trying to develop a database using hash-table. > As you can see, creating a file that contains the data of hash-table. > > (setq data-directory "~/(path)/hashtest") > (with-current-buffer (find-file-noselect data-directory) > =A0 (let ((h (make-hash-table :test 'equal))) > =A0 =A0 (puthash "think" "hard" h) > =A0 =A0 (puthash "go" "this" h) > =A0 =A0 (puthash "come" "that" h) > =A0 =A0 (puthash "went" "gone" h) > =A0 =A0 (puthash "category" "bad" h) > =A0 =A0 (puthash "why" "how" h) > =A0 =A0 (puthash "what" "on" h) > =A0 =A0 (insert (format "%S" h)) > =A0 =A0 (save-buffer))) > > in the "hashtest" file, > > #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 dat= a > ("think" "hard" "go" "this" "come" "that" "went" "gone" "category" "bad" > "why" "how" "what" "on" ...)) > > But for checking, > > (with-current-buffer > =A0 =A0 (find-file-noselect data-directory) > =A0 (let ((ht (read (current-buffer)))) > =A0 =A0 (gethash "go" ht))) > > gives an error, > > Debugger entered--Lisp error: (error "Odd number of elements in hashtable > data")... > > "Odd number" does not make sense to me at all. > Could anyone help me out? > > Thanks in advance! > > soichi I get a different error: End of file during parsing. In my case it is because the point remains at the end of the buffer after the hash table has been serialized in the associated file. In order to make it work I had to change the code which reads the hash table to the following: (with-current-buffer (find-file-noselect data-directory) (let ((ht (read (current-buffer)))) (goto-char (point-min)) ;; move the point to the beginning of the buffer (gethash "go" ht)))