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: Thu, 26 Jul 2018 10:43:52 +0200 Message-ID: References: <7e8dd084-7ab9-c2ce-1d6c-e673fa998f11@cs.ucla.edu> <6f720005-b5e4-5d1c-b4e8-a8992c7635c4@cs.ucla.edu> <1c3c61c4-f93f-3bea-f6ed-b89e1cdea89b@cs.ucla.edu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1532594530 21893 195.159.176.226 (26 Jul 2018 08:42:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 26 Jul 2018 08:42:10 +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 Thu Jul 26 10:42:05 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 1fibqX-0005Zn-3d for geb-bug-gnu-emacs@m.gmane.org; Thu, 26 Jul 2018 10:42:05 +0200 Original-Received: from localhost ([::1]:32841 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fibsc-00018E-5D for geb-bug-gnu-emacs@m.gmane.org; Thu, 26 Jul 2018 04:44:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53506) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fibsT-00017t-Kr for bug-gnu-emacs@gnu.org; Thu, 26 Jul 2018 04:44:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fibsQ-00086y-MT for bug-gnu-emacs@gnu.org; Thu, 26 Jul 2018 04:44:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:53249) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fibsQ-00086r-Gs for bug-gnu-emacs@gnu.org; Thu, 26 Jul 2018 04:44:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fibsQ-00044E-9t for bug-gnu-emacs@gnu.org; Thu, 26 Jul 2018 04:44: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: Thu, 26 Jul 2018 08:44: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.153259464115620 (code B ref 32252); Thu, 26 Jul 2018 08:44:02 +0000 Original-Received: (at 32252) by debbugs.gnu.org; 26 Jul 2018 08:44:01 +0000 Original-Received: from localhost ([127.0.0.1]:58267 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fibsO-00043s-Mu for submit@debbugs.gnu.org; Thu, 26 Jul 2018 04:44:00 -0400 Original-Received: from mail-wr1-f48.google.com ([209.85.221.48]:41726) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fibsN-00043g-L7 for 32252@debbugs.gnu.org; Thu, 26 Jul 2018 04:43:59 -0400 Original-Received: by mail-wr1-f48.google.com with SMTP id j5-v6so855222wrr.8 for <32252@debbugs.gnu.org>; Thu, 26 Jul 2018 01:43:59 -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=g0doT7jObbI8Aiauf2OpRqV1St1oJq5Bt7EVfhYbrZ4=; b=omfEhe9mokUQxNoN4JyyCIEN51PicaTBaJ4UwFS9cL0f1Hrzqqc5U3XSHnM4VnWrYi XRKyi5Rpa0LSf+htKxghv9XhnxZOSfV2XpuTv7kWlno9U0FHeQPGYXx2/ZWtGMrS/Hhd K9aqRaa9byiTRoLgO4W0FhMT+fqfA7bIyJG0MQHZzxsiVLXC4JQiM4TNS0AuLmRgTJkL 1fCBmpkwn3XIWavQlvji2jyoZpXPu8qjhQZgin85Hw9PCN3/6wxwbCVGTmP/EAY6Y3G1 mrVjtj6nY2oCnTiSxcSC7Vbjqe9/b8uvQ8VvoqLPpjFiLRN1SfjuFAyaL3CQICQPbCBB 2NMQ== 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=g0doT7jObbI8Aiauf2OpRqV1St1oJq5Bt7EVfhYbrZ4=; b=gRIw3yFetd18JbTFs/2xtTT5ibmrCgdfCsN4I6cDPkuaUynyUStyHV9EsAImzA17AJ MIavP6mx8muiaP72TRNz+thcWSXrhi18zVRHuDB6QRPOArkmuzKGJ4GJR8A2mRzzVry5 +Qfm+HGdXbDMTwZSCG3I1ron/XhQRWF58GQfWH3GU1qf6zVODjdRuic8miE+BVaCG+hk RZNN4RqlqIDpVcMsb3IPp/HvLWN0kKJ9Ku1WjfKhiqssk6D/a9Tyoaklttz+mCVLdBEf ySfBjhgnjcfOFqYJFVydECO3kXcFK/uidfmwI0AIWiqDpxrk2hTpRdlXPYAKsJq0acep 22wA== X-Gm-Message-State: AOUpUlGgRlaoz3NDwGUttVWeJjZ6r1Vsw+Z15K5jVu0+YKWB6OafN2FT aVFeXIZRat4wBwHMtfoUTdih2FEo X-Google-Smtp-Source: AAOMgpcIqGsn5LC3xiFA8YOTJDrg5xshK6Sm6LonddmLcSePozpLuHdMNY3LYJU++NgHBNYa2hLJ7A== X-Received: by 2002:adf:f091:: with SMTP id n17-v6mr862333wro.49.1532594633751; Thu, 26 Jul 2018 01:43:53 -0700 (PDT) Original-Received: from caladan ([37.186.181.82]) by smtp.gmail.com with ESMTPSA id e133-v6sm1773296wma.33.2018.07.26.01.43.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 Jul 2018 01:43:53 -0700 (PDT) In-Reply-To: <1c3c61c4-f93f-3bea-f6ed-b89e1cdea89b@cs.ucla.edu> (Paul Eggert's message of "Thu, 26 Jul 2018 00:59:56 -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:148955 Archived-At: On Thu, Jul 26 2018, Paul Eggert wrote: > Helmut Eller wrote: > >> What's more interesting: >> (format "%x" (lognot 8)) => "-9" >> or >> (format "%x" (lognot 8)) => "3ffffffffffffff7" >> >> For me, the first version is totally useless. > > Shrug. It's what Common Lisp and Scheme do, and it works pretty well > once you get used to it. It's because I happen to know a thing or two about Common Lisp that I know that I almost always would prefer the way that Emacs Lisp prints negative fixnums. > Programs that need negative integers > displayed modulo some power of 2 can use the mod or logand functions; > that's the mathematically right way to do it anyway, and it's > machine-independent. Do you think I don't know that? It's always possible to write a helper function that does the formatting in the variant that you need. >> Of course there have been proposals: Do your bignum stuff with a >> different format specifier. > > And prohibit %x on bignums? That would make little sense. It would prohibit only negative bignums just like negative flonums are forbidden. Besides I still think that it would make much more sense to print flonums the way %a does in C; another reason for having %a or another format specifier to do the hex conversion in a world with bignums. > Common Lisp and Scheme don't have any such prohibition; why should > Emacs Lisp? Because Emacs Lisp was very successful without bignums. Even more successful than most other Lisps with all their fancy bignums, complex numbers, ratios and other numeric stuff that hardly anyone needs. And the stuff that almost everybody would like to have like, fast unboxed arithmetic, is not offered in a reliable and portable way. >> Here is another proposal: Add a read syntax for unsigned fixnums like >> #x3fffffffffffffffu or alternatively #xu3fffffffffffffff. > > That's heading down the wrong path. Emacs Lisp does not have unsigned > fixnums, so why add a syntax for a data type that does not exist? And > Emacs Lisp should not add such a data type, as it is a low-level > machine concept unsuitable for Lisp, is not needed in Emacs Lisp, and > would cause unnecessary complexity in documentation and > implementation. In my mind Emacs does have negative fixnums and there are various ways to write negative fixnums. Of course a special syntax is not absolutely needed but it may be convenient. Helmut