unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattiase@acm.org>
To: Po Lu <luangruo@yahoo.com>
Cc: Eli Zaretskii <eliz@gnu.org>,
	stefankangas@gmail.com, 56641@debbugs.gnu.org
Subject: bug#56641: Deprecate `lsh`
Date: Wed, 20 Jul 2022 13:57:27 +0200	[thread overview]
Message-ID: <752C35EB-B86F-4D5B-863D-D9AFDFE20A66@acm.org> (raw)
In-Reply-To: <877d48bhch.fsf@yahoo.com>

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.






  parent reply	other threads:[~2022-07-20 11:57 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-19 13:38 bug#56641: Deprecate `lsh` Mattias Engdegård
2022-07-19 13:52 ` Eli Zaretskii
2022-07-19 14:44   ` Stefan Kangas
2022-07-19 15:40     ` Eli Zaretskii
2022-07-19 15:53     ` Mattias Engdegård
2022-07-19 16:20       ` Stefan Kangas
2022-07-19 16:38         ` Eli Zaretskii
2022-07-20  1:25           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-20  2:36             ` Eli Zaretskii
2022-07-20  3:20               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-20 11:24                 ` Eli Zaretskii
2022-07-20 11:57                 ` Mattias Engdegård [this message]
2022-07-20 12:21                   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-20 12:44                     ` Eli Zaretskii
2022-07-20 14:30                     ` Mattias Engdegård
2022-07-21  1:43                       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-21  7:47                         ` Mattias Engdegård
2022-07-23  7:26 ` Lars Ingebrigtsen
2022-07-23 10:32   ` Mattias Engdegård
2022-07-23 11:20     ` Lars Ingebrigtsen
2022-07-23 13:18       ` Eli Zaretskii
2022-07-23 13:20         ` Lars Ingebrigtsen
2022-07-23 15:42     ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-23 16:51       ` Mattias Engdegård
2022-07-24  3:38         ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=752C35EB-B86F-4D5B-863D-D9AFDFE20A66@acm.org \
    --to=mattiase@acm.org \
    --cc=56641@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=luangruo@yahoo.com \
    --cc=stefankangas@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).