From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tom Tromey Newsgroups: gmane.emacs.devel Subject: Re: Using the GNU GMP Library for Bignums in Emacs Date: Thu, 05 Jul 2018 15:29:17 -0600 Message-ID: <87tvpdnzgy.fsf@tromey.com> References: <29f933ac-a6bf-8742-66a7-0a9d6d3e5a88@disroot.org> <83bmecy6fx.fsf@gnu.org> <0d3175d8-d996-651e-b221-71978bde3a65@cs.ucla.edu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1530826082 10450 195.159.176.226 (5 Jul 2018 21:28:02 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 5 Jul 2018 21:28:02 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jul 05 23:27:58 2018 Return-path: Envelope-to: ged-emacs-devel@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 1fbBnC-0002X0-4G for ged-emacs-devel@m.gmane.org; Thu, 05 Jul 2018 23:27:58 +0200 Original-Received: from localhost ([::1]:54882 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbBpH-0005Mn-GX for ged-emacs-devel@m.gmane.org; Thu, 05 Jul 2018 17:30:07 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33243) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbBp7-0005MV-TS for emacs-devel@gnu.org; Thu, 05 Jul 2018 17:29:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fbBp4-0000T6-Ni for emacs-devel@gnu.org; Thu, 05 Jul 2018 17:29:57 -0400 Original-Received: from gateway33.websitewelcome.com ([192.185.146.130]:29998) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fbBp4-0000Lr-CK for emacs-devel@gnu.org; Thu, 05 Jul 2018 17:29:54 -0400 Original-Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway33.websitewelcome.com (Postfix) with ESMTP id 48F23A4B4 for ; Thu, 5 Jul 2018 16:29:42 -0500 (CDT) Original-Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id bBoYfeBf3bXuJbBoifoF6M; Thu, 05 Jul 2018 16:29:41 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=DtBr0pCZgWYH1QPQwJeQkAqR0baksaAb/GUw+nsbCe8=; b=FdgwKlET1FIECRE97aNKFgYAJ4 B/w5pwyf8hefGe6hUZZdJoqqWigUPTLbQDHawferMPjaI0hhgqFG+aIi19L79mhh4Ozv8BR5y7OxU 1oGIwy2qQ32/sNsL59Hgu7rOG; Original-Received: from 75-166-85-72.hlrn.qwest.net ([75.166.85.72]:59826 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1fbBoU-002Sy8-V1; Thu, 05 Jul 2018 16:29:19 -0500 X-Attribution: Tom In-Reply-To: (Stefan Monnier's message of "Sun, 22 Apr 2018 23:03:18 -0400") X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.85.72 X-Source-L: No X-Exim-ID: 1fbBoU-002Sy8-V1 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-85-72.hlrn.qwest.net (bapiya) [75.166.85.72]:59826 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 192.185.146.130 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:226978 Archived-At: >>>>> "Stefan" == Stefan Monnier writes: Stefan> There are several steps to adding GMP support. Some of those steps Stefan> might involve non-trivial decisions. But the first few steps should be Stefan> straightforward enough: Stefan> A- add a new "bignum" type Stefan> B- add new operations on them (this might be enough to start using them in Calc) Stefan> C- add support for bignums to some of the pre-existing functions (e.g. +) Stefan> D- add support for bignums to more of the pre-existing functions Stefan> E- add support for bignums "everywhere" where numbers are usually allowed. Stefan> Anything before D/E should be fairly straightforward. Stefan> I consider "support for read&print" to fall somewhere in D or maybe E. I've got some of this working. I've added configury for GMP and added a new bignum type. I've made some operations work -- comparisons, abs, float. I haven't made arith_driver bignum-aware yet, so no "+", "-", etc. This doesn't look too hard. Some part of "format" work but I haven't tried to handle all the cases discussed in this thread. A few things need to be discussed. 1. Should the C core change the names of things like NUMBERP to FIXNUMP? Similarly should make_number -> make_fixnum? I could do this with sed I suppose. In the meantime I've tweaked the necessary spots in a somewhat ugly way. 2. What is (type-of 5)? Right now 'integer, but arguably perhaps 'fixnum is correct. Gerd's branch did this. 3. Should intbig_to_lisp et al be converted to use bignums? I'm inclined to say no, for compatibility. 4. Should it be possible to make a "low-valued bignum"? For testing I have a make-bignum function that turns a fixnum into a like-valued bignum. However, maybe this should just not be possible. (And most likely make-bignum should just be deleted before merging any of this.) I've pushed this to my github but I could push it to a branch on savannah if that's useful. I don't know the current branch naming convention, so I'd need guidance there. Tom