From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: LdBeth Newsgroups: gmane.emacs.devel Subject: Re: sqlite3 Date: Sat, 18 Dec 2021 18:39:20 +0800 Message-ID: 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> <8FA7417E-7C56-42A0-8533-DDB604965EBA@mit.edu> Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=ISO-8859-7 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28854"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.2 (x86_64-apple-darwin18.7.0) MULE/6.0 (HANACHIRUSATO) Cc: Po Lu , "emacs-devel@gnu.org" To: Qiantan Hong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Dec 18 11:41:13 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 1myX9M-0007My-F0 for ged-emacs-devel@m.gmane-mx.org; Sat, 18 Dec 2021 11:41:12 +0100 Original-Received: from localhost ([::1]:48116 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1myX9K-0001cn-Tu for ged-emacs-devel@m.gmane-mx.org; Sat, 18 Dec 2021 05:41:10 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:56408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1myX8A-0000we-Gm for emacs-devel@gnu.org; Sat, 18 Dec 2021 05:39:58 -0500 Original-Received: from [203.205.251.84] (port=38716 helo=out203-205-251-84.mail.qq.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1myX7z-0005Hd-0Z for emacs-devel@gnu.org; Sat, 18 Dec 2021 05:39:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1639823977; bh=08R7YifsNJ+OQEYLdqzyh+Sdb8Z44GtGCQWHYIZauTU=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=v7ZnYYy7jUOo8JSLR2mB3Y/j37mACmSqQfwXMJKG0p1vkrZyayDDuBymQLWF1TRZq 4cjGqy9BguAS467inbzxS4qiBi2R2nbgcqMEe3UX47rbQm/MWn9V5VeK6LTp2mO0Y4 P20pP7tMI308qmuae6GMTvvh4Tb1DwrSo/dtpFXE= Original-Received: from Costume-Party.local ([39.189.56.217]) by newxmesmtplogicsvrszb6.qq.com (NewEsmtp) with SMTP id 9E4A9832; Sat, 18 Dec 2021 18:39:36 +0800 X-QQ-mid: xmsmtpt1639823976ty9rfnvcu X-QQ-XMAILINFO: M4rL4XrBLbwK7rabHi5vm0vcDHB+40DkzW4Q53wputNgG6IDzHILLqoXMQsQ0Y iSrB1qU6IytIAU0aPWL2JcJ26CdbLeyJ1TFfmnETNFMpSK2eHoOAVcbIO5NEV5ouKGqNUlt2e27N udWHjak0T1Bg/eI/mAL+W3++8GmU1b/7wp5gSjG211ODrMhJoPfQ0DeT9qIBTCl6HZoHuAlL49vp l+gsaUuYDnM7CMYgQtXr5TVAmAHM7jGGk/QLjFwTw6Lp4B8343A99dP/8z93rmSD2AmJ7NnFNEDH 4lOcYTDakLIvRz8X4hlGv4FnqSJB7oNwqE2vlWcZDk8/cFzCYLi3ygOkgZzRO2w8SSJQW20zTS6/ TBSmxlufIxOuZifvS6VNjyEG8Z2j0fsUB2sTIHCeMw8rCioYqFHBBbCxYTCrKYXpkGEgItxgYX3y vCRFTnxg16DdZDTHwbK9sXHoHr7Z3vPBlqL3Leu2sNvw61/4dkRjBxeSM+u7jkSuL7ZgpIrW7wWG L10C3sp5v2ADcER3z/8lIPg2i75T1lx/oUCV3snVMh3Zzz9sYthiz4aLHUHypN5Yiq7P6xMmZXCy gSKXaGAQ/GlPJMDmjIUcQeUeZHL5S44IaU7hMDfQ/Rl4brF/xBMdOKPw20i9xb0wyP2NrvO3/oYV 4EwyUBTY7aUj71PYb11bteLdjRm/w41Hvb4krfPznUkWtHg5noSmr4y5StuZGNDSDRN5Ms5qZSD/ 3LSmSlG1WoZ87d9q6ObJnq2ZyEJ1+bvGcOTOJDEgdZYviS83bFeP1s3o37pVZkKckqW1mHt2EOAe tBHof41BFPLras8XxF+snvang/EGcGL4Y= Original-Received: by Costume-Party.local (Postfix, from userid 501) id 6C4CF203CFFDF2; Sat, 18 Dec 2021 18:39:20 +0800 (CST) X-OQ-MSGID: In-Reply-To: <8FA7417E-7C56-42A0-8533-DDB604965EBA@mit.edu> <87ee6afe6b.fsf_-_@yahoo.com> X-Face: $7|yD%Lji?.p'#Ya#/C7iZ!+-!NJjcGAgDR]\PSw$5:"t{7P+VEqKM:>~f#x)H2jckGF($uh>W~_Qc/,O|&mg(HAmk,P?*}P]1w1Y6R_Eu/njc; o>(_\1T$MB3M3oPTM:cv83P$`O)F{ID*m}x3S#}+?w!"kF@h<68U0'ti>$=J2.&mQw~Z^#:2FP(bF)(Y:}1r~W~@(5IR!|_C*Fy*gERgk6F!; m"e"hC`I; TMK1O_l&i+Ja)s9d2; {xTNv&gp/>w>#aSg)P:%$oVI*V[LFED=+xNrHX-!#}\U] X-Host-Lookup-Failed: Reverse DNS lookup failed for 203.205.251.84 (failed) Received-SPF: pass client-ip=203.205.251.84; envelope-from=andpuke@foxmail.com; helo=out203-205-251-84.mail.qq.com X-Spam_score_int: 6 X-Spam_score: 0.6 X-Spam_bar: / X-Spam_report: (0.6 / 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_FROM=0.001, HELO_DYNAMIC_IPADDR=1.951, MSGID_FROM_MTA_HEADER=0.001, 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:282276 Archived-At: It is not about having hashconsing at the Emacs Lisp heap. I think the context we are talking is save/retrive Lisp objects from a external store, it maybe SQLite, maybe a text based backend. Let's restricting it to the objects stored in that store. Apparently you can not directly call lisp rplaca/rplacd a con cell stored in a database, you need a certain kinds of read/write protocol, so it is sane to assume that objects are at some level immutable in the datastore. (Or maybe you want the object store to be very transparent, but I guess it would be hard for a language without Metaobject Protocol) Actually the resists!.el (posted in the other related thread) do borrowed some concepts from immutable data storage. Hash-consing involves the implementation detail of comparing a object of the host language (in this case, Emacs Lisp), to something represented inside the storage (the text, maybe). The Lisp printer shipped with Emacs Lisp already does some kinds of comparison when print-circle is on. It is reasonable to ask for a finer control over the comparison method being used. EQUAL is a concrete function, and it is possible to replace it by any user definable equivalence relation. On Sat, 18 Dec 2021 17:35:56 +0800, Po Lu wrote: >=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. On Sat, 18 Dec 2021 17:06:22 +0800, Qiantan Hong wrote: >=20 > LDB> It seems no one has yet pointed out "preserving EQness" is actually > LDB> hash-consing[1], a technique has been developed in Lisp and now well > LDB> known in Functional Programming communities. > It is definitely not. >=20 > The feature of hash-consing is exactly not preserving EQness, > or, under hash-consing EQ and EQUAL degenerate to the same thing > (Aka, intensional and extensional identity degenerates), effectively > removing the concept of EQ and object identity from the language all=20 > together. >=20 > That=A2s the reason why hash-consing is widely used in purely functional > programs, where programs only cares about extensional identity. >=20 > EQness/object identity/intensional identity is significant under mutation, > and actually affects the semantics. >=20 > (defun eq (x y) > (let ((probe (gensym)) > (save (car x))) > (rplaca x probe) > (prog1 > (eq (car y) probe) > (rplaca x save)))) >=20 > In layman=A2s term: even if two objects=A2 value look the same, they may > or may not be the same object. The difference become apparent when > you poke one, and the other may or may not change. >=20 > Hash-consing in a mutable language *does not* preserve EQ-ness,=20 > the object identity is arbitrarily merged, and the structure of the refer= ence=20 > graph is not preserved.