emacs-devel
[Top][All Lists]
Advanced

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

Re: sqlite3


From: Qiantan Hong
Subject: Re: sqlite3
Date: Sat, 18 Dec 2021 09:06:22 +0000

> 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.
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]