emacs-devel
[Top][All Lists]
Advanced

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

Re: Warnings about keymaps


From: Stefan Monnier
Subject: Re: Warnings about keymaps
Date: Tue, 15 Sep 2009 09:40:27 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

>> It could, but it shouldn't complain about assignment to a constant,
>> since the defvar will not perform any assignment.  I.e. maybe a warning
>> is OK, but not the warning we currently get.

> How about this? Or perhaps the defvar should just be silently
> optimized away, like the default-boundp test seems to be trying to do.

This warning might be OK, but I have some issues with it:
- most importantly: it doesn't solve the problem at hand which is how
  to get rid of the other warning.
- what's its use?  It's not like we've seen lots of bugs where people
  use both defconst and defvar for a variable.
- Finally, if the defconst+defvar is really what you want to do (as in
  the present case where the defconst and the defvar both come from
  macros that we may not want to change), how do you silence
  the warning?


        Stefan


> *** bytecomp.el 10 Sep 2009 06:22:30 -0000 2.258
> --- bytecomp.el 14 Sep 2009 23:30:56 -0000
> ***************
> *** 4025,4032 ****
>               (let ((tmp (make-symbol "defconst-tmp-var")))
>                 `(funcall '(lambda (,tmp) (defconst ,var ,tmp))
>                           ,value))
>             ;; `defvar' sets `var' only when unbound.
> !           `(if (not (default-boundp ',var)) (setq-default ,var ,value))))
>       (when (eq fun 'defconst)
>         ;; This will signal an appropriate error at runtime.
>         `(eval ',form)))
> --- 4036,4046 ----
>               (let ((tmp (make-symbol "defconst-tmp-var")))
>                 `(funcall '(lambda (,tmp) (defconst ,var ,tmp))
>                           ,value))
> +           (if (memq var byte-compile-const-variables)
> +               (byte-compile-warn "attempt to defvar constant `%s' \
> + has no effect" var)
>               ;; `defvar' sets `var' only when unbound.
> !             `(if (not (default-boundp ',var)) (setq-default ,var ,value)))))
>       (when (eq fun 'defconst)
>         ;; This will signal an appropriate error at runtime.
>         `(eval ',form)))




reply via email to

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