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

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

bug#27016: possible bug in `defsetf'


From: Michael Heerdegen
Subject: bug#27016: possible bug in `defsetf'
Date: Fri, 26 May 2017 01:40:16 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Hello,

I wonder now if the definition of `eval-and-compile' as defmacro is
correct.  Maybe Stefan can help (I CC'd him), he may also want to look
at the rest of the report...

npostavs@users.sourceforge.net writes:

> > #+begin_src emacs-lisp
> > (macroexpand '(defsetf foo bar))
> > ==>
> > '(lambda
> >    (do &rest args)
> >    (gv--defsetter 'foo
> >                   (lambda
> >                     (val &rest args)
> >                     `(,'bar ,@args ,val))
> >                   do args))
> > #+end_src
>
> I don't understand where that quote comes from.

The `defsetf' expands to an `eval-and-compile'.  The `eval-and-compile'
expands to a quoted constant, see its definition (as defmacro).


> > When you compile a file with this content:
> >
> > #+begin_src emacs-lisp
> > (eval-and-compile
> >   (unless nil
> >     (defsetf foo bar)))
> > #+end_src
> >
> > you get an empty .elc.
> >
> > Isn't that strange?
>
> Yeah, even stranger...

AFAIU, when compiled, `eval-and-compile' macroexpands its body (see the
defconst of `byte-compile-initial-macro-environment').  So what is
compiled is essentially

#+begin_src emacs-lisp
(if nil nil
  '(closure
    (t)
    (do &rest args)
    (gv--defsetter 'foo
                   (lambda
                     (val &rest args)
                     `(,'bar ,@args ,val))
                   do args)))
#+end_src

and that's just discarded.


Michael.





reply via email to

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