emacs-devel
[Top][All Lists]
Advanced

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

Re: Hash consing (was: Re: sqlite3)


From: Philipp
Subject: Re: Hash consing (was: Re: sqlite3)
Date: Sat, 18 Dec 2021 14:46:07 +0100


> Am 18.12.2021 um 10:35 schrieb Po Lu <luangruo@yahoo.com>:
> 
> LdBeth <andpuke@foxmail.com> writes:
> 
>> 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 has main features that:
>> 
>> 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
>> 
>> It is definitely useful, but I think we could make it into a separated
>> package, probably.
> 
> 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.
> 

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.


reply via email to

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