Hi Marc, > a number of modules (like the hash module or the list module) allow > the user to specify callbacks (e.g. a comparison function). > Unfortunately, these procedures do not take a context parameter, which > can be a problem because C lacks closures.
Is this a practical, actual problem, or only a theoretical one? I would hesitate to change (or duplicate) public API, when there is no practical need. Note that the lack of context can be remedied by - use of per-thread variables, or - use of nested functions [1], or - storing a pointer to the necessary context in the list elements. > The original qsort function in stdlib.h has the same problem. Glibs > has remedied the problem by introducing qsort_r. qsort_r is only portable to glibc systems, FreeBSD, and macOS. And yet, no one has requested a substitute for it in gnulib. IMO this indicates that few programs need this function. Bruno [1] https://gcc.gnu.org/onlinedocs/gcc-10.1.0/gcc/Nested-Functions.html