From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Using the GNU GMP Library for Bignums in Emacs Date: Tue, 10 Jul 2018 16:33:35 -0400 Message-ID: References: <29f933ac-a6bf-8742-66a7-0a9d6d3e5a88@disroot.org> <83bmecy6fx.fsf@gnu.org> <0d3175d8-d996-651e-b221-71978bde3a65@cs.ucla.edu> <87tvpdnzgy.fsf@tromey.com> <4c2a814f-c254-29e5-39cf-11b5f2e5c9c8@cs.ucla.edu> <49d8ba62-c9a5-9203-d882-8e900b441ff3@cs.ucla.edu> <8e0320d9-e0d0-2b57-57cc-2df4399f133c@cs.ucla.edu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1531254705 8196 195.159.176.226 (10 Jul 2018 20:31:45 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 10 Jul 2018 20:31:45 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jul 10 22:31:41 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 1fczIT-00022n-4o for ged-emacs-devel@m.gmane.org; Tue, 10 Jul 2018 22:31:41 +0200 Original-Received: from localhost ([::1]:49656 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fczKZ-0002gl-Vd for ged-emacs-devel@m.gmane.org; Tue, 10 Jul 2018 16:33:52 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52492) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fczKT-0002gQ-71 for emacs-devel@gnu.org; Tue, 10 Jul 2018 16:33:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fczKQ-0001wt-2m for emacs-devel@gnu.org; Tue, 10 Jul 2018 16:33:45 -0400 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:54505) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fczKP-0001wY-S3 for emacs-devel@gnu.org; Tue, 10 Jul 2018 16:33:42 -0400 Original-Received: from lechazo.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id w6AKXZVg011614; Tue, 10 Jul 2018 16:33:36 -0400 Original-Received: by lechazo.home (Postfix, from userid 20848) id BEDDA602BB; Tue, 10 Jul 2018 16:33:35 -0400 (EDT) In-Reply-To: <8e0320d9-e0d0-2b57-57cc-2df4399f133c@cs.ucla.edu> (Paul Eggert's message of "Tue, 10 Jul 2018 09:01:44 -0700") X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6326=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6326> : inlines <6745> : streams <1792170> : uri <2671644> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 132.204.246.22 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:227225 Archived-At: > If so, why would someone want to specialize a method just for fixnums, as > opposed to a method for integers? cl-generic has no trouble dispatching on a supertype of that returned by `type-of`. IOW if `type-of` returns `fixnum` and `bignum` cl-generic has no difficulty finding that these are applicable for methods that stipulate an `integer` argument (or a `number` argument for that matter). But the other way around is a lot more difficult, so as long as fixnums and bignums are visibly two different types, I think it makes more sense for `type-of` to return different values for those two cases. > The basic operations +, -, * etc. aren't specialized for fixnums. Actually, they are, but this is done by manual type-testing in the C code, not with cl-defmethod. > Are you anticipating adding specialized variants fixnum-+, fixnum--, > fixnum-*, etc., and then having people write methods with all this in > mind? Or maybe having the bytecode optimizer use them? Not at all, no. > If not, then I'm still not following the advantage of having (type-of 5) > return something other than 'integer'. For backward compatibility reasons, I agree that (type-of 5) should continue returning `integer` (tho returning `fixnum` would be better otherwise), but (type-of ) doesn't suffer from such a backward compatibility requirement, so it would be preferable for it to return `bignum`. I wonder on the other hand, why you think it'd be bad for (type-of ) to return `bignum` instead of `integer`. Stefan