From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tom Newsgroups: gmane.emacs.help Subject: hash strangeness Date: Sun, 2 Nov 2014 11:20:37 +0000 (UTC) Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1414927326 23173 80.91.229.3 (2 Nov 2014 11:22:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 2 Nov 2014 11:22:06 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Nov 02 12:21:59 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XktEM-000519-UT for geh-help-gnu-emacs@m.gmane.org; Sun, 02 Nov 2014 12:21:59 +0100 Original-Received: from localhost ([::1]:56383 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XktEM-0005yx-GX for geh-help-gnu-emacs@m.gmane.org; Sun, 02 Nov 2014 06:21:58 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47101) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XktDT-00054s-Fs for help-gnu-emacs@gnu.org; Sun, 02 Nov 2014 06:21:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XktDJ-0000Ex-8Y for help-gnu-emacs@gnu.org; Sun, 02 Nov 2014 06:21:03 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:39059) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XktDJ-0000E2-2g for help-gnu-emacs@gnu.org; Sun, 02 Nov 2014 06:20:53 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XktDH-0004Zv-BT for help-gnu-emacs@gnu.org; Sun, 02 Nov 2014 12:20:51 +0100 Original-Received: from 92-249-133-166.pool.digikabel.hu ([92.249.133.166]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 02 Nov 2014 12:20:51 +0100 Original-Received: from adatgyujto by 92-249-133-166.pool.digikabel.hu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 02 Nov 2014 12:20:51 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 45 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: sea.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 92.249.133.166 (Mozilla/5.0 (Windows NT 6.1; rv:33.0) Gecko/20100101 Firefox/33.0) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:100686 Archived-At: Here's a code which gives me some headache. It's silly, because it was shortened from a longer code to demonstrate the problem. It is supposed to count something in elisp functions, though the condition is removed, so with this code the count should be 1 for every function. So the code checks if the function is already in the hash and if not then it inserts new info for that function: (let ((h (make-hash-table :test 'equal))) (mapatoms (lambda (s) (let* ((name (symbol-name s)) (info (gethash name h))) (unless info (setq info '(count 0))) (setq info (plist-put info 'count (1+ (plist-get info 'count)))) (puthash name info h)))) (pop-to-buffer "*testout*") (erase-buffer) (maphash (lambda (name info) (insert (format "%s %s" (plist-get info 'count) name) "\n")) h)) The new info is newly created in the lambda function (it is a plist, because in the real code there are other fields too), yet for some reason the same info structure is used for all iterations. I tried to debug it and at the "(unless info" part info is nil and then it is set to the previous value, though it should be a new value. Am I missing something here? GNU Emacs 24.1.1