From: Mattias EngdegÄrd Date: Sat, 23 Jul 2022 10:15:08 +0000 (+0200) Subject: Warn about calls to `lsh` (bug#56641) X-Git-Tag: emacs-29.0.90~1447^2~784 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=72a457e92e3b13b071b29afa8912a244843d04bc;p=emacs.git Warn about calls to `lsh` (bug#56641) * lisp/subr.el (lsh): Warn when compiled; recommend `ash`. * etc/NEWS: Add note. --- diff --git a/etc/NEWS b/etc/NEWS index 780dbfa51e8..a1fea5d6d68 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -3230,6 +3230,12 @@ to preserve the old behavior, apply '(take N LIST)' returns the first N elements of LIST; 'ntake' does the same but works by modifying LIST destructively. +--- +** Calling 'lsh' now elicits a byte-compiler warning. +'lsh' behaves in somewhat surprising and platform-dependent ways for +negative arguments and is generally slower than 'ash' which should be +used instead. + * Changes in Emacs 29.1 on Non-Free Operating Systems diff --git a/lisp/subr.el b/lisp/subr.el index 510a77dbc8d..06da5e28730 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -528,6 +528,11 @@ i.e., subtract 2 * `most-negative-fixnum' from VALUE before shifting it. This function is provided for compatibility. In new code, use `ash' instead." + (declare (compiler-macro + (lambda (form) + (when (byte-compile-warning-enabled-p 'suspicious 'lsh) + (byte-compile-warn-x form "avoid `lsh'; use `ash' instead")) + form))) (when (and (< value 0) (< count 0)) (when (< value most-negative-fixnum) (signal 'args-out-of-range (list value count)))