[alexandria-devel] Re: [PATCH] COPY-HASH-TABLE

Tobias C. Rittweiler tcr at freebits.de
Fri Mar 14 13:51:13 UTC 2008


"Nikodemus Siivola" <nikodemus at random-state.net> writes:

> All copying functions except COPY-TREE and COPY-ALIST functions in CL
> are shallow, and neither :COPY-FN nor :KEY is very documentative as an
> argument name.
>
> What's the use-case for this?

What's the use-case of COPY-HASH-TABLE itself?

I personally have needed it in two cases:

  a) "the following code analyzes the hash-table in some possibly
      destructive way; I'm interested in the result of the analysis."

  b) "the following codes frob the hash-table possibly destructively;
      I'm possibly interested in the difference between the original and
      the frobbed version."

In case a) the analysis is sometimes not about the aggregate data
structure stored in the hash-table, but only about the content of a slot
of that data structure. So, when copying the hash-table, we only KEY
what's really needed (either by giving a pointer to the original thing,
or by making a copy of it) --- rationale: The analysis sees only what it
needs, so there's less opportunity for corruption.

In case b): If the code frobs destructively, the destructive operation
is often not only restricted to the hash-table per se, but also to the
data structures contained in the hash-table.


Notice that COPY-HASH-TABLE is still shallow by default. It's just that
hash-tables are used in more complex situations, justifying a bit more
flexibility.

  -T.




More information about the alexandria-devel mailing list