[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#56641: Deprecate `lsh`
From: |
Mattias Engdegård |
Subject: |
bug#56641: Deprecate `lsh` |
Date: |
Wed, 20 Jul 2022 13:57:27 +0200 |
20 juli 2022 kl. 05.20 skrev Po Lu <luangruo@yahoo.com>:
> It might be rare, but there's nothing wrong with using lsh for its
> intended purpose, which is handling negative numbers correctly in
> several different situations.
The purpose of `lsh` is not breaking old code. (It used to have a different
purpose but it vanished when bignums were introduced.)
There is no reasonable use for it in new code. Even in the unlikely event of
code that just happens to need that sort of quirky behaviour, it is much better
implemented explicitly where it's used, in terms of `ash`.
> Byte-compiler warnings are supposed to point out problems. Using lsh is
> not a problem
You are right that most uses of `lsh` are perfectly innocuous but that's
because they are used in a way where `ash` would give the same result. This is
often true even when the return values of `lsh` and `ash` differ, as in
(logand (lsh x -16) #xff)
which would give the same result even for negative x if `lsh` were replaced
with `ash`.
However there is a potential problem since the behaviour of `lsh` is strongly
platform-dependent, and it's impossible to write correct code without taking
that into account (consider replacing -16 with -24 above). Users may not be
aware of how it works and mistakenly think it is the 'unsigned' or 'logical'
shift that they know from other languages.
- bug#56641: Deprecate `lsh`, (continued)
- bug#56641: Deprecate `lsh`, Eli Zaretskii, 2022/07/19
- bug#56641: Deprecate `lsh`, Stefan Kangas, 2022/07/19
- bug#56641: Deprecate `lsh`, Eli Zaretskii, 2022/07/19
- bug#56641: Deprecate `lsh`, Mattias Engdegård, 2022/07/19
- bug#56641: Deprecate `lsh`, Stefan Kangas, 2022/07/19
- bug#56641: Deprecate `lsh`, Eli Zaretskii, 2022/07/19
- bug#56641: Deprecate `lsh`, Po Lu, 2022/07/19
- bug#56641: Deprecate `lsh`, Eli Zaretskii, 2022/07/19
- bug#56641: Deprecate `lsh`, Po Lu, 2022/07/19
- bug#56641: Deprecate `lsh`, Eli Zaretskii, 2022/07/20
- bug#56641: Deprecate `lsh`,
Mattias Engdegård <=
- bug#56641: Deprecate `lsh`, Po Lu, 2022/07/20
- bug#56641: Deprecate `lsh`, Eli Zaretskii, 2022/07/20
- bug#56641: Deprecate `lsh`, Mattias Engdegård, 2022/07/20
- bug#56641: Deprecate `lsh`, Po Lu, 2022/07/20
- bug#56641: Deprecate `lsh`, Mattias Engdegård, 2022/07/21
bug#56641: Deprecate `lsh`, Lars Ingebrigtsen, 2022/07/23