bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#12813: gv-define-simple-setter can evaluate VAL more than once


From: Glenn Morris
Subject: bug#12813: gv-define-simple-setter can evaluate VAL more than once
Date: Tue, 06 Nov 2012 02:47:25 -0500
User-agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)

Package: emacs
Version: 24.2.50

I don't know if you will consider this a bug.
gv-define-simple-setter with FIX-RETURN non-nil evaluates VAL twice.
This may lead to unintended behaviour.

Artificial example in `emacs -Q':

(defun foo (x)
  (car x))

(defun foo-set (x y)
  (setcar x y))

(gv-define-simple-setter foo foo-set t)

(setq bar '(1 2 3))
(setq i 0)

(setf (foo bar) (setq i (1+ i)))   ; -> 1
bar                                ; -> (2 2 3) rather than (1 2 3)


defsetf in 24.2 was documented to not have this issue
(info "(cl)Customizing Setf")
[...]

(let ((temp VALUE))
  (UPDATE-FN ARG1 ARG2 ARG3 temp)
  temp)

So at the very least this will be relevant if http://debbugs.gnu.org/12812
gets the "obvious" fix.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]