From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Stefan Merten <smerten@oekonux.de>
Cc: Jonathan Yavner <jyavner@member.fsf.org>, emacs-devel@gnu.org
Subject: Re: testcover: setf-method and treatment of `defcustom'
Date: Mon, 10 Sep 2012 23:40:11 -0400 [thread overview]
Message-ID: <jwvipbldzik.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <6900.1347261102@theowa.merten-home.homelinux.org> (Stefan Merten's message of "Mon, 10 Sep 2012 09:11:42 +0200")
> 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))
next prev parent reply other threads:[~2012-09-11 3:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-10 7:11 testcover: setf-method and treatment of `defcustom' Stefan Merten
2012-09-11 3:40 ` Stefan Monnier [this message]
2012-09-12 20:38 ` Stefan Merten
2012-09-13 13:09 ` Stefan Monnier
2012-09-13 20:45 ` Stefan Merten
2012-09-16 9:06 ` Stefan Merten
2012-09-18 21:37 ` Stefan Monnier
2012-09-12 19:32 ` Stefan Merten
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvipbldzik.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=jyavner@member.fsf.org \
--cc=smerten@oekonux.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.