From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: testcover: setf-method and treatment of `defcustom' Date: Mon, 10 Sep 2012 23:40:11 -0400 Message-ID: References: <6900.1347261102@theowa.merten-home.homelinux.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1347334822 5499 80.91.229.3 (11 Sep 2012 03:40:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 11 Sep 2012 03:40:22 +0000 (UTC) Cc: Jonathan Yavner , emacs-devel@gnu.org To: Stefan Merten Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 11 05:40:24 2012 Return-path: Envelope-to: ged-emacs-devel@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 1TBHKp-0001Ld-Fm for ged-emacs-devel@m.gmane.org; Tue, 11 Sep 2012 05:40:23 +0200 Original-Received: from localhost ([::1]:49029 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBHKl-0002UF-KV for ged-emacs-devel@m.gmane.org; Mon, 10 Sep 2012 23:40:19 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:42462) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBHKi-0002UA-Jr for emacs-devel@gnu.org; Mon, 10 Sep 2012 23:40:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TBHKh-0006dU-Cw for emacs-devel@gnu.org; Mon, 10 Sep 2012 23:40:16 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:51623) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBHKh-0006cX-8W for emacs-devel@gnu.org; Mon, 10 Sep 2012 23:40:15 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai0FAG6Zu09soXr9/2dsb2JhbABEsEiDSYEIghUBAQQBViMFCwsOJhIUGA0kiBwFugmQRAOjM4FYgwWBOho X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="198027684" Original-Received: from 108-161-122-253.dsl.teksavvy.com (HELO fmsmemgm.homelinux.net) ([108.161.122.253]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 10 Sep 2012 23:40:13 -0400 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 6160AAE3A5; Mon, 10 Sep 2012 23:40:11 -0400 (EDT) In-Reply-To: <6900.1347261102@theowa.merten-home.homelinux.org> (Stefan Merten's message of "Mon, 10 Sep 2012 09:11:42 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.182 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:153229 Archived-At: > No setf-method known for testcover-after Does one of the 2 patches work? > I looked into this and found `defsetf' in `cl-macs'. `testcover-after' > is a function which has only some side effect. I think > (defsetf testcover-after (idx val) (store) > (list 'progn > (list 'testcover-after idx val) > (list 'setf val store))) > does the right thing. At least the error messages described above > vanish for me. I'm not sure what we should do, but the above doesn't sound quite right. > AFAICS the only thing which can go wrong with this setf-method seems > to be the double evaluation of `val' In (setf (testcover-after IDX (aref A I)) V), your defsetf will be called with a `val' that's a temporary variable bound to the value of (aref A I), so double evaluation is not a problem. But your `(setf ,val ,store) will end up changing some temporary variable rather than changing the I'th slot of the A vector. My 1st patch has the downside that it doesn't call testcover-after at all. The reason is that I don't know what VAL to set in IDX when we do things like (push VAL (testcover-after IDX PLACE)): should it be the value read before pushing VAL onto it, or the value set afterwards? The second patch chooses to call testcover-after when setting the value. > I still had another error left, however. > Value of form marked with `1value' does vary: ... I'll let Jonathan comment on this (as well as on my suggested gv-expanders). Stefan === modified file 'lisp/emacs-lisp/testcover.el' --- lisp/emacs-lisp/testcover.el 2012-01-19 07:21:25 +0000 +++ lisp/emacs-lisp/testcover.el 2012-09-11 03:09:45 +0000 @@ -447,6 +447,7 @@ (defun testcover-after (idx val) "Internal function for coverage testing. Returns VAL after installing it in `testcover-vector' at offset IDX." + (declare (gv-expander (lambda (do) (gv-get val do)))) (cond ((eq (aref testcover-vector idx) 'unknown) (aset testcover-vector idx val)) === modified file 'lisp/emacs-lisp/testcover.el' --- lisp/emacs-lisp/testcover.el 2012-01-19 07:21:25 +0000 +++ lisp/emacs-lisp/testcover.el 2012-09-11 03:38:33 +0000 @@ -447,6 +447,13 @@ (defun testcover-after (idx val) "Internal function for coverage testing. Returns VAL after installing it in `testcover-vector' at offset IDX." + (declare (gv-expander (lambda (do) + (gv-letplace (getter setter) val + (funcall do getter + (lambda (store) + (macroexp-let2 nil s store + `(progn (testcover-after ,idx ,s) + ,(funcall setter s))))))))) (cond ((eq (aref testcover-vector idx) 'unknown) (aset testcover-vector idx val))