Am Fr., 6. Aug. 2021 um 04:13 Uhr schrieb John Cowan <xxxxxx@ccil.org>:
Here's the design I'm going with for make-dictionary:

make-dictionary accepts two arguments, a DTD and a comparator; however, if the dictionary type does not accept a comparator, pass #f.  The function dict-comparator will return #f if the various functions are fixed.

I still don't understand why you want a comparator here.  As some dictionary types do not accept a comparator, it is a strong hint that it is the wrong abstraction to pass a comparator to make-dictionary.

Instead, provide something like (dtd-copy dtd1 dtd2 dict1 dict2).
 
make-modified-dtd accepts a DTD and procname-proc pairs; any procnames not mentioned are drawn from the DTD argument.  A common use case is replacing the definition of make-dictionary so that other arguments can be passed to the type-specific constructor.

It should also be accompanied by the corresponding syntax.  Maybe it makes sense to overload make-dtd so that no two constructors are needed.
 
dtd-ref returns a specific procedure from a DTD given its procname. This allows you to pluck individual procedures from a DTD.

Changing procnames to be exported variables with integer values to index into the DTD rather than symbols.

Can you explain this?
 
=====

I'm considering adding some additional functions from SRFI 124:

-unfold: as you would think.

dict=?, dict<?, etc.  Compare dictionaries for equality, subset, etc.  A value comparator is passed in.

dict-union(!), dict-intersection(!), etc.  Functional and linear-update versions of these operations.

-range=(!), range<(!), etc.  Return subsets whose keys are =, <, etc.

-dict-fold/reverse (maybe)

The following will only work on ordered dictionaries; a new predicate ordered-dictionary? is provided to see if they are applicable or signal dictionary-errors.

-min-key, -max-key: Returns the smallest and largest key in the dictionary.

-key-successor, -key-predecessor: Return preceding and following key.

Comments?

Looks good to me, but dict-fold with more than one seed is more important.

In the context of R7RS, the *requirement* to signal an error looks alien; in general, this is only required for what R6RS would call "errors" and not for what R6RS would call "violations".

PS I am wondering whether compound objects could be the basis for DTDs to allow later extensibility (even by the user).