From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Pip Cet Newsgroups: gmane.emacs.devel Subject: Re: hash-consing bignums and eq==eql Date: Wed, 29 Aug 2018 13:32:11 +0000 Message-ID: References: <20180821204437.16880.99611@vcs0.savannah.gnu.org> <20180821204439.62390209A6@vcs0.savannah.gnu.org> <53d0c06e-2383-955a-0a17-650fd842b483@cornell.edu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1535549493 29814 195.159.176.226 (29 Aug 2018 13:31:33 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 29 Aug 2018 13:31:33 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Aug 29 15:31:28 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 1fv0ZD-0007c4-Lb for ged-emacs-devel@m.gmane.org; Wed, 29 Aug 2018 15:31:27 +0200 Original-Received: from localhost ([::1]:43161 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fv0bK-0004ry-4S for ged-emacs-devel@m.gmane.org; Wed, 29 Aug 2018 09:33:38 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47094) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fv0ab-0004rf-Gu for emacs-devel@gnu.org; Wed, 29 Aug 2018 09:32:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fv0aZ-0000Z9-IN for emacs-devel@gnu.org; Wed, 29 Aug 2018 09:32:53 -0400 Original-Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]:37429) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fv0aY-0000Xs-6w for emacs-devel@gnu.org; Wed, 29 Aug 2018 09:32:51 -0400 Original-Received: by mail-lf1-x12c.google.com with SMTP id j8-v6so4305777lfb.4 for ; Wed, 29 Aug 2018 06:32:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ln5sGNx4QVYzPxg76wb6FASMe9QcaLj4mDtDlSPhjqk=; b=jRSufLg+VSvY7N9MqnMwFpv/C35rjyFHC6DM9jXAstqu0Xvu7e92ySmOerEKdVqJoi tnt62SA0VlGBY01vwFUBM6aLThhYWZwUYaqkZ1qCgSzz1K+hGuon5dQpQqgr8+55vyQD lWMkHyjbpG1qQFyhb/z8b3Q/3K0s88gyQfW3zNOFrRKO3p291qqu0oYWYgTq+OPl8UmC mozAZWdaphWUhCrR8GPApLzefOxVSNga4p9belZlIvebxSAL/VFq/cPryCwrl+WsfqgZ 1K8DkqY+UiZEc7cwr6AUv6lBpUKGLM1G1x5Mm94eNoUtr3xEZukRyFPW7g8Wt145OYm2 8LDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ln5sGNx4QVYzPxg76wb6FASMe9QcaLj4mDtDlSPhjqk=; b=rqsaEoUZFoDwtpRVCScmZQBi1+dDm+albEYoOESWj2imPaIXYHDgqp0LACb5ZwrOYy d31mPHws3pBI9Elza0YPPdUbb4P/4UZfD+zBTmoGLz/KJvxO0Kni4xF+5y6vrxcgEw3A yBohjhDykOT9yqjUwJ8oexspC+zf+DlR6d7lL8DbU1yVgf1oD4Lau+mTr44WR/Ix1Dg/ lKePlOfQvdeFeNpYhU4u3oyCxrLXA5TctkVfusNLkrnXiVlX0iAhKBAHv2574OqxvE1S tnzWCPZ3hB6F4bd0xRf6YeT7ntYc74szqDB5r0qutn2cJ9hkBQqPYWpLdyfSJ+PdswnZ j9Tw== X-Gm-Message-State: APzg51DCGNscllvhwrxtMKaN+jRGG80hi9n+PJYrkI/Ipf1iMPjFf096 BjdCLS+o06j6ONoZd26WTVEOGqJsPSQ2JDChQPlL0A== X-Google-Smtp-Source: ANB0VdZuMrLMjUJNArHucbi0w5MhZT1RdP9ykqnqNkFKkWrJRHjbg/Ws9WL+QRaVhgWWyo838TzuRLjYaFHxTvAqQy0= X-Received: by 2002:a19:f83:: with SMTP id 3-v6mr4328616lfp.131.1535549568892; Wed, 29 Aug 2018 06:32:48 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::12c 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:229051 Archived-At: On Tue, Aug 28, 2018 at 2:08 PM Stefan Monnier wrote: > BTW, hash-consing bignums would have the following advantages: > - EQ is equivalent to EQL for all integers. I think that's the one to focus on, instead of splitting the vote between the hash-consers and the slow-EQers. Most users, even Lisp programmers, won't care how it's done under the hood, but the distinction between eq and eql for integers leads to subtle bugs that are best excluded by design, IMHO. > Admittedly, if we used a dedicated tag for bignums, eql could turn into > > BIGNUM_OR_FLOAT_P (x) ? slow_eql (x, y) : (x == y); > > where BIGNUM_OR_FLOAT_P can be just as efficient as FLOATP, so it > would be cheap enough (IMO) to make `eq` an alias for `eql`. I rather think it hinges on the question of whether eq = eql should hold for floats. As you point out, bignums are already much faster than they used to be, and your theory and my benchmark established an upper bound for the price of hash-consing that is acceptable on 64-bit machines. However, I'd like to point out that if floating-point infinities are used along with integers, things could get confusing again; I still have a slight preference for slow EQ compared to hash-consing only bignums: I think hash-consing floats is problematic unless we have float immediates (which would include infinities). Okay, that's complicated. Five options, in my order of preference: 1. Slow EQ 2. float immediates, hash-cons the remaining floats, hash-cons bignums 3. hash-cons bignums, leave floats alone 4. hash-cons bignums and all floats 5. the status quo