hash-table-set! and insertion order Shawn Wagner (17 Nov 2023 23:14 UTC)
Re: hash-table-set! and insertion order Daphne Preston-Kendal (17 Nov 2023 23:32 UTC)
Re: hash-table-set! and insertion order Daphne Preston-Kendal (17 Nov 2023 23:38 UTC)
Re: hash-table-set! and insertion order Sudarshan S Chawathe (30 Aug 2024 22:57 UTC)

Re: hash-table-set! and insertion order Daphne Preston-Kendal 17 Nov 2023 23:32 UTC

On 18 Nov 2023, at 00:14, Shawn Wagner <xxxxxx@gmail.com> wrote:

> I'm throwing together an implementation of this for Racket, and ran into the first of probably many questions:
>
> The description of hash-table-set! says "Whenever there is a previous association for a key, it is deleted". Does that mean the key gets moved to the end of the insertion order list from wherever it was as if it was deleted and re-inserted in two steps, instead of just updating the value of the existing entry and leaving the order unchanged?

For what it’s worth, my implementation does the latter.

I think this is also the sensible thing to do. It’s familiar to programmers (it’s what Python and Ruby’s ordered hash tables do, at least), and it avoids creating a dead hash table entry for no real reason. (Or in a doubly-linked-list based implementation, it avoids doing pointer manipulation for no reason.)

This spec language is taken over from SRFI 125 where the point was moot; it should be clarified.

dpk