GNU bug report logs - #27016
possible bug in `defsetf'

Previous Next

Package: emacs;

Reported by: Rafael D Sorkin <rsorkin <at> perimeterinstitute.ca>

Date: Mon, 22 May 2017 06:40:01 UTC

Severity: minor

Tags: fixed, patch

Found in versions 24.4, 25.2

Fixed in version 26.1

Done: npostavs <at> users.sourceforge.net

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Rafael D Sorkin <rsorkin <at> perimeterinstitute.ca>
To: npostavs <at> users.sourceforge.net
Cc: 27016 <at> debbugs.gnu.org, Rafael D Sorkin <rsorkin <at> perimeterinstitute.ca>
Subject: bug#27016: possible bug in `defsetf'
Date: Mon, 22 May 2017 18:03:08 -0400
Thanks, I was wondering about that myself.  Is there a standard
for elisp (or common lisp) that would determine whether eager
macro expansion is an error in this case?

I would expect that a `defun' or `defsetf' etc which is within a
conditional would not be executed until it was known whether the
condition was satisfied.  The opposite behavior seems
counter-intuitive to me.

But if you decide that this behavior is not a bug, then please
let me know, so that I can adapt to it in the future.

 > tags 27016 - unreproducible
 > found 27016 24.4
 > found 27016 25.2
 > quit
 > 
 > Rafael D Sorkin <rsorkin <at> perimeterinstitute.ca> writes:
 > 
 > > Following your suggestion I tried starting with "emacs -Q" and
 > > got the same results as you did.  However if I (require 'cl)
 > > then the bug returns.  (I normally require CL automatically on
 > > starting emacs.)  So perhaps it's an incompatibility between CL
 > > and the new way that defsetf is implemented.
 > 
 > Oh, right, I see it now.  It happens in 24.4 and later.  I'm not sure
 > it's a bug though.  My guess is that the difference is eager
 > macroexpansion.  When I compile, then I get the same behaviour with 24.3
 > (that's my earliest working Emacs build) as well.
 > 
 >     $ emacs -Q -batch -l cl -f batch-byte-compile bug-27016-defsetf.el 
 > 
 >     In toplevel form:
 >     bug-27016-defsetf.el:1:1:Warning: cl package required at runtime
 >     bug-27016-defsetf.el:3:1:Warning: global/dynamic var `pair' lacks a prefix
 >     Wrote /home/npostavs/src/emacs/bug-27016-defsetf.elc
 >     $ emacs -Q -batch -l bug-27016-defsetf.elc
 >     pair: (0 . 4)
 > 
 > where bug-27016-defsetf.el has contents:
 > 
 >     (require 'cl)
 > 
 >     (defvar pair nil)
 >     (setq pair (cons 3 4))                  ; (3 . 4)
 >     (unless t
 >       (defalias 'foobar 'cons)
 >       (defsetf foobar setcar))              ; nil
 >     (setf (foobar pair) 0)                  ; 0       !
 > 
 >     (message "pair: %S" pair)

~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
 Rafael Sorkin
 Perimeter Institute for Theoretical Physics
 31 Caroline Street North
 Waterloo, ON  N2L 2Y5
 Canada
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-




This bug report was last modified 7 years and 290 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.