From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#32463: 27.0.50; (logior -1) => 4611686018427387903 Date: Sun, 19 Aug 2018 20:47:29 -0700 Organization: UCLA Computer Science Department Message-ID: References: <86mutll4w2.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1534736772 1704 195.159.176.226 (20 Aug 2018 03:46:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 20 Aug 2018 03:46:12 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 Cc: andrewjmoreton@gmail.com, 32463@debbugs.gnu.org To: rms@gnu.org, Pip Cet Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Aug 20 05:46:07 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1frb8p-0000Kv-JX for geb-bug-gnu-emacs@m.gmane.org; Mon, 20 Aug 2018 05:46:07 +0200 Original-Received: from localhost ([::1]:44924 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frbAv-0002WD-SP for geb-bug-gnu-emacs@m.gmane.org; Sun, 19 Aug 2018 23:48:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39730) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frbAn-0002W6-4j for bug-gnu-emacs@gnu.org; Sun, 19 Aug 2018 23:48:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1frbAi-0006px-6f for bug-gnu-emacs@gnu.org; Sun, 19 Aug 2018 23:48:09 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:49966) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1frbAi-0006pl-0e for bug-gnu-emacs@gnu.org; Sun, 19 Aug 2018 23:48:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1frbAg-0000KT-3t for bug-gnu-emacs@gnu.org; Sun, 19 Aug 2018 23:48:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 20 Aug 2018 03:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32463 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 32463-submit@debbugs.gnu.org id=B32463.15347368591234 (code B ref 32463); Mon, 20 Aug 2018 03:48:02 +0000 Original-Received: (at 32463) by debbugs.gnu.org; 20 Aug 2018 03:47:39 +0000 Original-Received: from localhost ([127.0.0.1]:54984 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1frbAJ-0000Jq-23 for submit@debbugs.gnu.org; Sun, 19 Aug 2018 23:47:39 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:41402) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1frbAH-0000Jd-OX for 32463@debbugs.gnu.org; Sun, 19 Aug 2018 23:47:38 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 03BC616087B; Sun, 19 Aug 2018 20:47:31 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id PHsONWVmN16i; Sun, 19 Aug 2018 20:47:30 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 3EBAC160885; Sun, 19 Aug 2018 20:47:30 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id BQUvugNjhqW2; Sun, 19 Aug 2018 20:47:30 -0700 (PDT) Original-Received: from [192.168.1.9] (unknown [47.154.30.119]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id BEFDB16087B; Sun, 19 Aug 2018 20:47:29 -0700 (PDT) In-Reply-To: Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:149611 Archived-At: Richard Stallman wrote: > What exactly is the problem with lsh and bignums? Is it for negative > numbers because there is no specific width? Yes, that's it. > One possible solution is to give lsh an optional third argument to > specify the nominal width of the first argument. The default could be > the width of a fixnum on your platform. Although we discussed something along those lines and could easily implement something, it's a bit trickier than it might sound at first, because of corner cases where the semantics are unclear. Here's one possible implementation (there are other approaches of course): (defun lsh (value count &optional width) (when (and (< value 0) (< count 0)) (let ((lo (if width (ash 1 (1- width)) most-negative-fixnum))) (when (< value lo) (signal 'args-out-of-range (list value count width))) (setq value (logand (ash value -1) (- -1 lo))) (setq count (1+ count)))) (ash value count)) I am skeptical whether the complexity of this extension is worth the effort to maintain and document. In a language with bignums, if you need a mask of bits you simply use a nonnegative integer, which means you can use ash without worrying about the corner cases that invariably afflict lsh. > How does Scheme handle the issue? Scheme does not have logical shifts, only arithmetic shifts. Logical shifts don't make that much sense once you have bignums.