From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Helmut Eller Newsgroups: gmane.emacs.bugs Subject: bug#32252: [PATCH] %o and %x now format signed numbers Date: Wed, 25 Jul 2018 08:58:25 +0200 Message-ID: References: <7e8dd084-7ab9-c2ce-1d6c-e673fa998f11@cs.ucla.edu> <6f720005-b5e4-5d1c-b4e8-a8992c7635c4@cs.ucla.edu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1532501828 10516 195.159.176.226 (25 Jul 2018 06:57:08 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 25 Jul 2018 06:57:08 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 32252@debbugs.gnu.org To: Paul Eggert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jul 25 08:57:04 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 1fiDjL-0002dK-TD for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 Jul 2018 08:57:04 +0200 Original-Received: from localhost ([::1]:45387 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fiDlS-0000RU-Qo for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 Jul 2018 02:59:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55819) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fiDlJ-0000Qx-PU for bug-gnu-emacs@gnu.org; Wed, 25 Jul 2018 02:59:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fiDlG-00082N-Rx for bug-gnu-emacs@gnu.org; Wed, 25 Jul 2018 02:59:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51011) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fiDlG-000817-K9 for bug-gnu-emacs@gnu.org; Wed, 25 Jul 2018 02:59:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fiDlG-0001ba-8O for bug-gnu-emacs@gnu.org; Wed, 25 Jul 2018 02:59:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Helmut Eller Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 25 Jul 2018 06:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32252 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 32252-submit@debbugs.gnu.org id=B32252.15325019186136 (code B ref 32252); Wed, 25 Jul 2018 06:59:02 +0000 Original-Received: (at 32252) by debbugs.gnu.org; 25 Jul 2018 06:58:38 +0000 Original-Received: from localhost ([127.0.0.1]:56029 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fiDkr-0001au-MW for submit@debbugs.gnu.org; Wed, 25 Jul 2018 02:58:37 -0400 Original-Received: from mail-wm0-f43.google.com ([74.125.82.43]:40879) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fiDkn-0001ad-CI for 32252@debbugs.gnu.org; Wed, 25 Jul 2018 02:58:33 -0400 Original-Received: by mail-wm0-f43.google.com with SMTP id y9-v6so3995086wma.5 for <32252@debbugs.gnu.org>; Tue, 24 Jul 2018 23:58:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=qjc1rKjCnuTGeqq1Nj87up939+9SY5DqYJQgzEvoVdQ=; b=n2smibjVBTjN2CVZlzWrCSxdezpOyDMnwDdMn6/uL7zGi/V7w14RBAnQ2GIDAgYQJu +tRmGDdH/uy4o8H+ypc9NPoTxw1RW1H4saieART8AjgwRq28X9n14ubcdMU//3CURflr gEjufoK2xL4/Un1tHE7iCSUD9G861HtQ6vZmQD9utrzm8dgoe++cEomJIrKtcheU2rGV mCB0tBZYFqVLX7AxmRvKeY0Zfb1HNl3Xf87CjhLQrj+wsKpYm9UAVM2dqORMcNERrrP6 wdB9KtBZi5iPsRLjfGph3Ei0sMZuLGhLr4OwJyt5AtqwgjwilI5IfKMtp1dRBdo2TocI 5PGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=qjc1rKjCnuTGeqq1Nj87up939+9SY5DqYJQgzEvoVdQ=; b=EpBEAWD92jOeLsguVfPaWtkXwj3l/68DGepMfk63ZhBSlnhB6xg5kfcS7kaRl/xrzw gOLdW6GI1DAxnKLDh1FvgiQcVHMBf2SsFa2nt8x6OmpojKCnppW4n/mJKcEhNNbGf3gI /S+cM36QbfgcwLHz8Jlopx7sm44Bzs7OW7gsDxf55JUJV9AhT1i/HbYyX9z+0FJ2YmLd 7ciycBFtcjbjov1tZ/YPzO64QXlwLQ0f1HD+EZx+lIDAlbwNENG07mZ7eLy7giiZ3P3N 6RU1aYXjpG8ibECSCblPKIQVtqGWODTQgKThVFc7EVbD/os94PT/QleGoHeeR7sSy7pu Qjew== X-Gm-Message-State: AOUpUlF2vCkP03DWkjbpoueQahcOYLOR5fpUJUVtKGTI350U8KQds80H UOaxau4HsIKRZw7j6PtT0xENZ5WG X-Google-Smtp-Source: AAOMgpftDhQBv/xxvEAl4kMj+9BSMy9eScB4BpYf2adLHkC4lk3K87/fpP8rjFNf/Weorn4tqYjgpw== X-Received: by 2002:a1c:aa8f:: with SMTP id t137-v6mr3674903wme.54.1532501907438; Tue, 24 Jul 2018 23:58:27 -0700 (PDT) Original-Received: from caladan ([37.186.181.82]) by smtp.gmail.com with ESMTPSA id e7-v6sm24524483wrm.14.2018.07.24.23.58.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Jul 2018 23:58:26 -0700 (PDT) In-Reply-To: <6f720005-b5e4-5d1c-b4e8-a8992c7635c4@cs.ucla.edu> (Paul Eggert's message of "Tue, 24 Jul 2018 17:50:46 -0700") X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.0 (-) 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:148914 Archived-At: On Tue, Jul 24 2018, Paul Eggert wrote: > Helmut Eller wrote: > >> In practice, printf ("%x", (int)N) prints the bits in N as unsigned >> integer not as signed integer. > > That's two operations not one, and even there the results disagree > with what (format "%x" N) does. On every Emacs platform I've ever used > the C output begins with a different hex digit than the Emacs Lisp > output. Emacs has never done %x just like that unportable C code, and > likely will never do so. Nobody is arguing for printing the tag-bits. And what Emacs has done is fairly obvious to everybody. >> #x-1 maybe interesting to the read function but it's not interesting to >> humans. Humans want to see #x3fffffffffffffff. > > I doubt very much that most humans really want to see an error-prone > notation like that (can you easily spot the difference between it and > #x3ffffffffffffffff? I can't). And even if some humans did want it, > they won't get it on 32-bit Emacs. This whole idea is a bad approach > for Emacs. What's more interesting: (format "%x" (lognot 8)) => "-9" or (format "%x" (lognot 8)) => "3ffffffffffffff7" For me, the first version is totally useless. > What I expect most users would prefer is an approach where 'read' and > 'format' are inverses, e.g., (read (printf "#x%x" N)) returns N for > every integer N. Emacs doesn't do that now, and the proposed patch > fixes things so that it does. The inverse of read is print, not format or printf. > No other approach has been proposed that > would make much sense (that is, be portable, be easily extendible to > bignums, that sort of thing). Of course there have been proposals: Do your bignum stuff with a different format specifier. Here is another proposal: Add a read syntax for unsigned fixnums like #x3fffffffffffffffu or alternatively #xu3fffffffffffffff. >> you should have no problem with introducing an >> new specifier for this. > > I'd rather not, as the hex stuff has never worked right in Emacs and > we shouldn't be codifying old bugs. It was already codified in the documentation, even the much more dubios flonum case. It's really annoying when documented behavior changes. Helmut