Please excuse if I appear a bit confused (maybe I am), but from reading your recent posts I conclude that the only things you would like to be in the spec are:

1) The equality predicate of (make-mapping-comparator) and (make-hashmap-comparator) works even for mappings with different key comparators and returns #f in this case.

2) The (make-hashmap-comparator) provides a hash function applicable to all mappings.

3) The (make-mapping-comparator) provides a ordering predicate applicable to all pairs of mappings with the same key comparator.

Is it so?

Is it okay to add:

4) This specification speaks of equality of comparators. The exact equality predicate is implementation-dependent but always at least as fine as equal? (and no finer than eq?, of course).

And:

5) Whether =? works with mappings with different key comparators is not that much important, only if =? is used to describe the equality predicate of (make-mapping-comparator) or (make-hashmap-comparator).

Marc

Shiro Kawai <xxxxxx@gmail.com> schrieb am Mo., 24. Juli 2017 um 09:44 Uhr:
After rereading the paragraph "When mappings with different comparators are compared ...", I realized I failed to capture the nuance.  So it does refer to the comparator of comparators, but is not requiring such comparator to have ordering procedure or hash function.  It merely mentions that it is an error for such comparator to have compatible ordering procedure or hash function.  Correct?

To me, if the implementation provides ordering procedure or hash function for comparators, it is implicit that equality predicate to test comparator equivalence is compatible for them, so I don't think it needs to be mentioned.

It can be mentioned that that implementation may provide ordering procedure or hash function for comparators, and mapping-comparator takes advantage of them in such a case.


On Sun, Jul 23, 2017 at 11:34 AM, Shiro Kawai <xxxxxx@gmail.com> wrote:


On Sun, Jul 23, 2017 at 4:43 AM, Marc Nieper-Wißkirchen <xxxxxx@nieper-wisskirchen.de> wrote:


What about: "... doesn't compare comparators using an equality predicate at least as fine as <code>equal?</code>..."?
 
* For =? to work, you don't need to order or hash comparators.

The paragraph you quoted above does not refer to =? but to the comparator returned by make-mapping-comparator.

Oh, I read it as the behavior of default comparator comparing key comparators, because it first talks about comparing comparators, then goes as  "doesn't provide a *compatible* ordering procedure or hash function, respectively" (emphasis mine), so this phrase appears to refer to the compatible ordering/hash for comparator comparison.   The ordering/hash procedure for value comparator is already referred to in the preceding paragraph, so I don't think we need to repeat that.

It's confusing, so let's draw out a call graph:

  (make-mapping-comparator value-comparator)
    - equivalence pred
          --- impl.dependent comparator-comparator (*)
                   --- impl.dependend comparator equivalence pred
          --- value-comparator
                   --- value-comparator equivalence pred
    - ordering procedure
          --- mapping's key comparator  (if key comparators don't match, error)
                   --- mappings' key comparator's ordering procedure
          --- value-comparator (for values)
                   --- value-comparator's ordering procedure
 
  (make-hashmap-comparator value-comparator)
    - equivalence pred
          --- impl.dependent comparator-comparator (*)
                   --- impl.dependend comparator equivalence pred
          --- value-comparator (for values)
                   --- value-comparator equivalence pred to compare values
    - hash function
          --- impl.dependent comparator hash function (*) (optional**)
          --- key comparator's hash function to hash keys
          --- value-comparator's hash function

So, if you're talking about comparing comparators (*), it needs neither ordering procedure nor hash function, and no point to mention that
(although it's better to have hash function in (**) case).
 
Also, are you inclined to allow mapping=? accepts mappings with different comparators?  I'm totally fine for it to restrict mappings with the same comparators; I'm concerned only for (=? (make-mapping-comparator value-cmpr) mapping1 mapipng2) case, and we can make explicit mention in the case there, without touching mapping=?.   I'm not sure which way is better.

If we allow mapping=? to accept mappings with different comparators and (mapping=? value-cmpr mapping1 mapping2) => #f for such mappings, then the equality test behavior is covered clearly in the paragraph before the added one I quoted, so I think the above quoted paragraph is unnecessary.  We only need to menthion ordering case:

We can add the clarifying paragraph to the "Comparator restrictions" section saying that comparators are compared by an implementation dependent equality predicate, which is at least as fine as "equal?".

The "Comparator restrictions" section mainly talks about value comparators, so probably it's better to make it clear that comparing comparators is a different topic.  How about something like this:

"The procedures in Submappings and Set-theory opertaions, and the comparator of mappings described in Comparators section, may deal with multiple mappings.  Unless otherwise noted, it is an error to pass mappings with different key comparators w.r.t. implementation dependend equality predicate, which is at least as fine as "equal?"."

And note the exception in mapping=? and equivalence predicate of make-mapping-comparator section that different key comparator yields #f for equivalence predicate.


    If <code>make-mapping-comparator</code> is imported from <code>(srfi
    146)</code>, the lexicographic ordering with respect to
    the keys (and, in case a tiebreak is neccessary, with respect to
    the ordering of the values) is used for mappings sharing a comparator.
    If its ordering procedure is invoked on mappings that don't share a comparator,
    it is an error unless the implementation's default comparator can order comparators,

That ordering has to be compatible with some sensible equality predicate. Note that the sample implementation of SRFI 128 does order comparators albeit trivially.

Right.  It's good to note that.
 
 
    or the implementation of (srfi 146) provides some way to order comparators.
    If the implementation can order comparators, it takes precedence before
    the lexicographic ordering.

Plus,

   If <code>make-hashmap-comparator</code> is imported from <code>(srfi 146 hash)</code>,
   the hash procedure of the returned comparator may use hashmap's key comparator for hash
   value calculation, if the implementation's default comparator is capable to hash comparators.

Shall (make-hash-map-comparator) provide a hash function if the implementation's default comparator isn't capable to hash comparators?


I think it should.  It's important that users can count on it.