From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/78320 Path: news.gmane.org!not-for-mail From: David Engster Newsgroups: gmane.emacs.devel,gmane.emacs.gnus.general Subject: Re: bizarre byte-compile issue, possibly due to EIEIO Date: Sun, 03 Apr 2011 11:34:42 +0200 Message-ID: <87sjtzznil.fsf@randomsample.de> References: <87hbahww99.fsf@lifelogs.com> <8762qxo4l3.fsf@lifelogs.com> <87lizs9w5e.fsf@randomsample.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1301823358 23759 80.91.229.12 (3 Apr 2011 09:35:58 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 3 Apr 2011 09:35:58 +0000 (UTC) Cc: ding@gnus.org, emacs-devel@gnu.org To: Ted Zlatanov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Apr 03 11:35:53 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q6Jir-0003Dw-73 for ged-emacs-devel@m.gmane.org; Sun, 03 Apr 2011 11:35:53 +0200 Original-Received: from localhost ([127.0.0.1]:50557 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q6Jip-0000ZW-TX for ged-emacs-devel@m.gmane.org; Sun, 03 Apr 2011 05:35:51 -0400 Original-Received: from [140.186.70.92] (port=57095 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q6Jig-0000UQ-4A for emacs-devel@gnu.org; Sun, 03 Apr 2011 05:35:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q6Jib-0004du-0V for emacs-devel@gnu.org; Sun, 03 Apr 2011 05:35:41 -0400 Original-Received: from v3-1008.vxen.de ([79.140.41.8]:40776) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q6Jia-0004dq-Hg for emacs-devel@gnu.org; Sun, 03 Apr 2011 05:35:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=randomsample.de; s=a; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To:Subject:Cc:To:From; bh=116a9eWPqM7XLtgt6ea920Z2DDFPo3z+gbkmyak7YDg=; b=KHhkKwr6+fxTiRTVAwu6oKhR7ijhuqfpx9RBs/gm26GjHIAP2HLsYEP2T5iCrr7/vJoNr8O3+mwe+N5Dr9/Db5KDwR6kjN59mn9ypMc0jpDUvQ/4itiFoW/snyfKy5fJ; Original-Received: from dslc-082-083-062-089.pools.arcor-ip.net ([82.83.62.89] helo=spaten) by v3-1008.vxen.de with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1Q6JiV-0000ju-LC; Sun, 03 Apr 2011 11:35:33 +0200 In-Reply-To: <87lizs9w5e.fsf@randomsample.de> (David Engster's message of "Sat, 02 Apr 2011 23:32:45 +0200") User-Agent: Gnus/5.110016 (No Gnus v0.16) Emacs/24.0.50 (gnu/linux) Mail-Followup-To: Ted Zlatanov , emacs-devel@gnu.org, ding@gnus.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) X-Received-From: 79.140.41.8 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:138085 gmane.emacs.gnus.general:78320 Archived-At: --=-=-= Content-Type: text/plain David Engster writes: > Ted Zlatanov writes: >> On Fri, 01 Apr 2011 15:29:38 -0500 Ted Zlatanov wrote: >> >> TZ> In other words, the registry.elc file is breaking the tests. I can't > >> TZ> figure out what's wrong, but it seems EIEIO-related. If I try to >> TZ> edebug, that evaluates the problematic methods (e.g. `registry-lookup') >> TZ> and then they don't exhibit the problem. >> >> TZ> Using "(eval-when-compile (require 'registry))" instead of >> TZ> "(require 'registry)" doesn't help. All the registry.el ERT tests pass. > > I can't really explain anything, but maybe I can at least shift the > blame. ;-) > If I rewrite your registry-lookup function to use 'mapcar' instead of > 'loop', the tests work as expected: [...] I tested a little bit more. I created a short test case which I attached to this mail. Run it by doing emacs --batch -L . -l bc-test -f bc-test If everything works, you should get Method with mapcar: (("20" "foo 20") ("30" "foo 30") ("40" "foo 40")) Method with loop: (("20" "foo 20") ("30" "foo 30") ("40" "foo 40")) Here's what I observe: * The 'mapcar' method always works. * If you don't byte-compile, the 'loop' method will also work. * If you byte-compile, the 'loop' method will fail with Emacs24 *before* the lexbind merge. After the lexbind merge, it works as expected. Note that the :initform evaluation will not work with the EIEIO version which ships with Emacs23. I remember some discussions regarding this issue; it's probably best to use an explicit constructor. I included it in the test case (you have to uncomment it). When using the class w/ constructor, you can also compile it under Emacs23, and the 'loop' method will then also fail. The funny thing is that Emacs24 *after* the lexbind merge cannot run that byte-compiled code from Emacs23; is that to be expected? -David --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=bc-test.el Content-Transfer-Encoding: quoted-printable (eval-when-compile (require 'cl)) (require 'eieio) (require 'eieio-base) (defclass bc-test-db (eieio-persistent) ((data :initarg :data :initform (make-hash-table :size 10000 :rehash-size 2.0 :test 'equal) :type t))) ;; ---------------------- ;; Emacs23 version: ;; older EIEIO bug ;; (eval-when-compile (setq filename nil)) ;; (defclass bc-test-db (eieio-persistent) ;; ((data :initarg :data ;; :type t))) ;; (defmethod initialize-instance :after ((this bc-test-db) slots) ;; "Set value of data slot of THIS after initialization." ;; (with-slots (data) this ;; (setq data (make-hash-table :size 10000 :rehash-size 2.0 :test 'equa= l)))) ;; ----------------------- (defmethod bc-test-get-mapcar ((db bc-test-db) keys) (let ((data (oref db :data))) (delq nil (mapcar (lambda (k) (when (gethash k data) (list k (gethash k data)))) keys)))) (defmethod bc-test-get-loop ((db bc-test-db) keys) (let ((data (oref db :data))) (loop for k in keys when (gethash k data) collect (list k (gethash k data))))) (defvar bc-test-mydb (bc-test-db "mydb")) (defun bc-test () (interactive) (let ((data (oref bc-test-mydb :data))) (dotimes (i 100) (puthash (number-to-string i) (format "foo %d" i) data))) (message "Method with mapcar: %s" (prin1-to-string (bc-test-get-mapcar bc-test-mydb '("20" "30" "40")))) (message "Method with loop: %s" (prin1-to-string (bc-test-get-loop bc-test-mydb '("20" "30" "40")))) ) --=-=-=--