emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sqlite3


From: LdBeth
Subject: Re: sqlite3
Date: Sat, 18 Dec 2021 18:39:20 +0800
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (Gojō) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.2 (x86_64-apple-darwin18.7.0) MULE/6.0 (HANACHIRUSATO)

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:
> 
> I wonder how hash consing would make sense in a language like Emacs Lisp
> that has `rplaca' and `rplacd'.
> 
> Perhaps we would need some kind of immutable cons data type.


On Sat, 18 Dec 2021 17:06:22 +0800,
Qiantan Hong wrote:
> 
> 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.
> 
> 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 
> together.
> 
> That’s the reason why hash-consing is widely used in purely functional
> programs, where programs only cares about extensional identity.
> 
> EQness/object identity/intensional identity is significant under mutation,
> and actually affects the semantics.
> 
> (defun eq (x y)
>   (let ((probe (gensym))
>         (save (car x)))
>     (rplaca x probe)
>     (prog1
>         (eq (car y) probe)
>       (rplaca x save))))
> 
> In layman’s term: even if two objects’ 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.
> 
> Hash-consing in a mutable language *does not* preserve EQ-ness, 
> the object identity is arbitrarily merged, and the structure of the reference 
> graph is not preserved.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]