From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philipp Newsgroups: gmane.emacs.devel Subject: Re: Hash consing (was: Re: sqlite3) Date: Sat, 18 Dec 2021 14:46:07 +0100 Message-ID: <57E58A64-95E7-4486-BEEC-06DC0E27DA02@gmail.com> References: <87tufmjyai.fsf@gnus.org> <87lf0nr2b4.fsf@gnus.org> <87fsqvp5ae.fsf@gnus.org> <87bl1jp51y.fsf@gnus.org> <187323C2-81D0-47B6-96C8-3D721EF7C003@mit.edu> <8735mvp454.fsf@gnus.org> <87ilvn1xur.fsf@gnus.org> <87fsqqxsr9.fsf@gnus.org> <679ECACB-C458-4C9E-B26A-72E8D81E0A24@mit.edu> <87ee6afe6b.fsf_-_@yahoo.com> Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.40.0.1.81\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11274"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "emacs-devel@gnu.org" To: Po Lu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Dec 18 15:41:15 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1myatf-0002my-Az for ged-emacs-devel@m.gmane-mx.org; Sat, 18 Dec 2021 15:41:15 +0100 Original-Received: from localhost ([::1]:40612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1myatd-00071I-UK for ged-emacs-devel@m.gmane-mx.org; Sat, 18 Dec 2021 09:41:13 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:40016) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1myarj-0003GB-Nj for emacs-devel@gnu.org; Sat, 18 Dec 2021 09:39:15 -0500 Original-Received: from [2a00:1450:4864:20::435] (port=33707 helo=mail-wr1-x435.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1myara-0003r9-V8 for emacs-devel@gnu.org; Sat, 18 Dec 2021 09:39:14 -0500 Original-Received: by mail-wr1-x435.google.com with SMTP id j9so9868694wrc.0 for ; Sat, 18 Dec 2021 06:39:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=lU5sOtKUQWVYhwWqm3vofuvclYlsR6iw2qIa7hbMg6A=; b=N7DLEAgCHToJ20Q/38ETOr75wHK+Z+O+Sci1XMDYwX/3ieqTS9Vx9vNMKrhNUUK/f6 KNu5d9BJI4Sm8cabf2TY0mJosz3RFT76tVEhyxkAsVnmmEBxrwlOQ0Hjtvok9ajbElA/ hWwgGokS7dsx/0xvccsfhTAAqCffqS4Br+IxEAsvtCf4GgqRLurJPwEefyrW88bte21d SaV/+2IAn6ej6tG3L3vo1y3fWapuMzfcUhXZptvi5hr3qbrEw0gepUHrCQDyyHiGFWKC fmbUasx9TYsYguibGC57FeSBa10s3DkPqF4leoG/+oY2YpWp2L1STOjhx6en59pYHlQN Ph5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=lU5sOtKUQWVYhwWqm3vofuvclYlsR6iw2qIa7hbMg6A=; b=juY/NUyMQWjQLZoSFbiFowhuS2i1VXMiYHdg5lPdSDwk6Mm4elZwXUn2ujrvXgUy86 u7WNEUcoYm6p4gu/v7hKAG3puzcBCaJzPvU94BJQ5unSFcjZm/nvbQY9Mg4W2z9xnYOT Vwf/fWdXCeIYZzjv+rD0H883zFFQn882TFjsYgOA5qifdzI5+5mg5vOwe/yK5pNV5J5v OdS5vBVEX7slMv9amcEaMRoQQAu9ndTBzbVX3HTz6kDZG2OLk2iOk/FM7BdpjEE8xDng xFEKtSbj7mJ0+vW2iEudHsvtzvHPZdvK50RytPdqFy7eaWFOhf0whspGeT648ln/XNzT qvDg== X-Gm-Message-State: AOAM531fY6eUAsS5m50ubzY4UtrkXrDs8zYOXFIR2CIZ2xWuaRbc/Uql gGzIn0tt2mvcjo5hL8vxtoQ= X-Google-Smtp-Source: ABdhPJzC5OSUCxRsRQPnX4LF3hVpU3x0xvHASFLCcMI/ig72eo7ogeC26LS6q5z+0I6Jv6BgwlOjzA== X-Received: by 2002:adf:97c2:: with SMTP id t2mr6373372wrb.577.1639838340667; Sat, 18 Dec 2021 06:39:00 -0800 (PST) Original-Received: from smtpclient.apple (p57aaf2ef.dip0.t-ipconnect.de. [87.170.242.239]) by smtp.gmail.com with ESMTPSA id g11sm5025030wri.73.2021.12.18.06.38.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Dec 2021 06:39:00 -0800 (PST) In-Reply-To: <87ee6afe6b.fsf_-_@yahoo.com> X-Mailer: Apple Mail (2.3693.40.0.1.81) X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::435 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=p.stephani2@gmail.com; helo=mail-wr1-x435.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:282317 Archived-At: > Am 18.12.2021 um 10:35 schrieb Po Lu : >=20 > LdBeth writes: >=20 >> It seems no one has yet pointed out "preserving EQness" is actually >> hash-consing[1], a technique has been developed in Lisp and now well >> known in Functional Programming communities. >>=20 >> It has main features that: >>=20 >> 1. Keeps only one copy of (structurally) EQUAL objects and therefore >> 2. reduce storage usage >> 3. reduce the time needed to do a EQUAL comparsion to EQ. >> 4. useful for function memoization >>=20 >> It is definitely useful, but I think we could make it into a = separated >> package, probably. >=20 > I wonder how hash consing would make sense in a language like Emacs = Lisp > that has `rplaca' and `rplacd'. >=20 > Perhaps we would need some kind of immutable cons data type. >=20 We already have that: for example, the result of evaluating the form '(1 = . 2) is an immutable cons cell. The immutability isn't enforced, = though: passing such a cons cell to `rplaca' will cause undefined = behavior, but typically not signal an error.=