Re: [New module] Persistent Hash Array Mapped Tries (HAMTs)

2020-10-11 Thread Marc Nieper-Wißkirchen
Am So., 11. Okt. 2020 um 10:20 Uhr schrieb Marc Nieper-Wißkirchen : > > Am So., 11. Okt. 2020 um 03:28 Uhr schrieb Bruno Haible : [...] > > * hamt_lookup: If the caller is allowed to modify the payload stored in the > > returned entry, this function should return a 'Hamt_entry *', not a > > '

Re: [New module] Persistent Hash Array Mapped Tries (HAMTs)

2020-10-11 Thread Marc Nieper-Wißkirchen
I am going to implement the following iterator API as well: /* An alternative interface to iterating through the entry of a hamt that does not make use of a higher-order function like hamt_do_while uses the opaque Hamt_iterator type. */ typedef struct hamt_iterator Hamt_iterator; /* Return

Re: [New module] Persistent Hash Array Mapped Tries (HAMTs)

2020-10-11 Thread Marc Nieper-Wißkirchen
Am So., 11. Okt. 2020 um 03:28 Uhr schrieb Bruno Haible : > > Hi Marc, > > Some comments: > > * GL_HAMT_THREAD_SAFE can be defined to 1 not only if > __STDC_VERSION__ >= 201112 && ! defined __STD_NO_ATOMICS__ > but also if > __GNUC__ + (__GNUC_MINOR >= 9) > 4 Fixed. > (see the other m

Re: [New module] Persistent Hash Array Mapped Tries (HAMTs)

2020-10-10 Thread Bruno Haible
Hi Marc, Some comments: * GL_HAMT_THREAD_SAFE can be defined to 1 not only if __STDC_VERSION__ >= 201112 && ! defined __STD_NO_ATOMICS__ but also if __GNUC__ + (__GNUC_MINOR >= 9) > 4 (see the other mail). * Still '#ifdef GL_HAMT_THREAD_SAFE'. * Typo s/comparision/comparison/ * Ham

Re: [New module] Persistent Hash Array Mapped Tries (HAMTs)

2020-10-10 Thread Marc Nieper-Wißkirchen
I have attached an improved version of the HAMT module to this email. Apart from improving the comments (which includes moving some documentation into the header file) and changing the things already discussed, I added a few more tests and three procedures for in-place updates. For example, you c

Re: [New module] Persistent Hash Array Mapped Tries (HAMTs)

2020-10-10 Thread Marc Nieper-Wißkirchen
Am Sa., 10. Okt. 2020 um 20:19 Uhr schrieb Paul Eggert : > #if __STDC_VERSION__ < 201112 || defined __STD_NO_ATOMICS__ > > which is a cleaner way of writing the negative of the above test. These days > there should be no reason to check whether __STDC_VERSION__ is defined, > generally it's cle

Re: [New module] Persistent Hash Array Mapped Tries (HAMTs)

2020-10-10 Thread Paul Eggert
On 10/10/20 8:04 AM, Marc Nieper-Wißkirchen wrote: #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined (__STD_NO_ATOMICS__) I am asking because there may be non-C11 compilers that nevertheless understand _Atomic. I suggest not worrying about this problem until we run into

Re: [New module] Persistent Hash Array Mapped Tries (HAMTs)

2020-10-10 Thread Marc Nieper-Wißkirchen
Am Sa., 10. Okt. 2020 um 19:41 Uhr schrieb Bruno Haible : > > Hi Marc, > > > Is there a special Gnulib way (or Autoconf macro) for the following test: > > > > #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && > > !defined (__STD_NO_ATOMICS__) > > > > I am asking because there may be

Re: [New module] Persistent Hash Array Mapped Tries (HAMTs)

2020-10-10 Thread Bruno Haible
Hi Marc, > > - +/* The public interface is documented in the file hamt.c. > > > > This is not good. As a user of the module, I would want to read *only* > > hamt.h and know how to use the public interface. In other words, hamt.h > > should have the functions' comments. > > I followe

Re: [New module] Persistent Hash Array Mapped Tries (HAMTs)

2020-10-10 Thread Bruno Haible
Hi Marc, > Is there a special Gnulib way (or Autoconf macro) for the following test: > > #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && > !defined (__STD_NO_ATOMICS__) > > I am asking because there may be non-C11 compilers that nevertheless > understand _Atomic. And there may

Re: [New module] Persistent Hash Array Mapped Tries (HAMTs)

2020-10-10 Thread Marc Nieper-Wißkirchen
Speaking of GL_HAMT_THREAD_SAFE: Is there a special Gnulib way (or Autoconf macro) for the following test: #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined (__STD_NO_ATOMICS__) I am asking because there may be non-C11 compilers that nevertheless understand _Atomic. Am S

Re: [New module] Persistent Hash Array Mapped Tries (HAMTs)

2020-10-10 Thread Marc Nieper-Wißkirchen
Am Sa., 10. Okt. 2020 um 16:54 Uhr schrieb Bruno Haible : > > Since you define GL_HAMT_THREAD_SAFE to either 0 or 1, you need > to test it through > #if GL_HAMT_THREAD_SAFE > not > #ifdef GL_HAMT_THREAD_SAFE > > Bruno Oh, yes... thanks!

Re: [New module] Persistent Hash Array Mapped Tries (HAMTs)

2020-10-10 Thread Bruno Haible
Since you define GL_HAMT_THREAD_SAFE to either 0 or 1, you need to test it through #if GL_HAMT_THREAD_SAFE not #ifdef GL_HAMT_THREAD_SAFE Bruno

Re: [New module] Persistent Hash Array Mapped Tries (HAMTs)

2020-10-10 Thread Marc Nieper-Wißkirchen
Hi Bruno, Am Sa., 10. Okt. 2020 um 16:35 Uhr schrieb Bruno Haible : > It is exciting to see such a datastructure with various application domains > [1] > in Gnulib! I'm glad that you like the idea. > > I haven't read through it line by line; nevertheless a couple of comments: A few more lines

Re: [New module] Persistent Hash Array Mapped Tries (HAMTs)

2020-10-10 Thread Bruno Haible
Hi Marc, > It implements a persistent version of Phil Bagwell's HAMTs, which has > been popularized by Clojure. HAMTs can be used when a persistent > (functional/pure) version of a data structure akin to hash tables is > needed. For example, the dynamic environment of a (possibly > multi-threaded)

[New module] Persistent Hash Array Mapped Tries (HAMTs)

2020-10-09 Thread Marc Nieper-Wißkirchen
Hi, after I have contributed two comparably trivial modules to Gnulib, I would like to contribute a less trivial module this time. It implements a persistent version of Phil Bagwell's HAMTs, which has been popularized by Clojure. HAMTs can be used when a persistent (functional/pure) version of a d