emacs-devel
[Top][All Lists]
Advanced

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

Re: Unused value of error-free function warning


From: Stefan Monnier
Subject: Re: Unused value of error-free function warning
Date: Tue, 09 Apr 2019 16:40:36 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

>   (byte-compile '(progn (list) t))
>   ;; => t
>
> with:
>
>   (byte-compile '(progn (+) t))
>   ;; => t (Warning: value returned from (+) is unused)

IIRC part of the reason is that it's safe to remove (list) so it's
a plain and simple optimization and the user may consciously rely on it
(e.g., I remember changing some `car` calls to `car-safe` in some macros
so as not to get warnings when the result is not used), whereas for (+)
it's not guaranteed to be safe (and it's only removed depending on
byte-compile-delete-errors).

> I understand that dead error-free expressions are just deleted, but
> shouldn't the user be warned of this?

Warnings are pretty tricky business because you don't want to annoy the
user with warnings about perfectly legitimate code.  So there's no hard
and fast rule and you can't always get it right; instead it's a murky
grey area where you try to minimize both the false positives and
false negatives.


        Stefan



reply via email to

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