Skip to content

Commit

Permalink
Revision of comparator equality and make-mapping-comparator
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Nieper-Wißkirchen committed Jul 24, 2017
1 parent 24fac7e commit 5acad4b
Showing 1 changed file with 19 additions and 24 deletions.
43 changes: 19 additions & 24 deletions srfi-146.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,16 @@ <h1>Specification</h1>
and <code>(srfi 146 hash)</code> (see below) are mutually disjoint.
</p>

<p>
This specification uses the notion of equality of comparators. The
exact equality predicate is left implementation-dependent but is
always at least as fine as <code>equal?</code> (and not finer
than <code>eq?</code>).
</p>

<p>
It is an error for any procedure defined in this SRFI to be invoked
on mappings with distinct comparators (in the sense
of <code>eq?</code>).
on mappings with distinct comparators, except if noted otherwise.
</p>

<p>
Expand Down Expand Up @@ -998,7 +1004,7 @@ <h2 id="Submappings">Submappings</h2>

<p>Furthermore, it is explicitly not an error
if <code>mapping=?</code> is invoked on mappings that do not share
the same comparator (in the sense of <code>eq?</code>). In that case, <code>#f</code> is returned.
the same (key) comparator. In that case, <code>#f</code> is returned.
</p>

<p><code>(mapping&lt;? <em>comparator</em> <em>mapping<sub>1</sub></em> <em>mapping<sub>2</sub></em> ...)</code></p>
Expand Down Expand Up @@ -1201,24 +1207,12 @@ <h2 id="Comparators">Comparators</h2>
Returns a comparator for mappings that is compatible with the equality
predicate
<code>(mapping=? <em>comparator</em> <em>mapping<sub>1</sub></em> <em>mapping<sub>2</sub></em>)</code>.
The comparator is obliged to provide ordering procedures when the
particular implementation of this SRFI (<i>e.g.</i> <code>(srfi
146)</code> or <code>(srfi 146 hash)</code>) requires comparators to
provide a comparison function, and is obliged to provide hash
functions when the implementation of this SRFI requires comparators
to provide a hash function. This allows mappings whose keys are
mappings themselves, and it allows to compare mappings whose values
are mappings.
</p>

<p>
When mappings with different comparators are compared, it is an
error if the implementation's default comparator doesn't compare
comparators using <code>eq?</code> as the equality predicate and
doesn't provide a compatible ordering procedure or hash function, respectively.
(If an implementation's
default comparator doesn't handle comparators, an implementation of
this SRFI may still provide its own ordering of comparators.)
If <code>make-mapping-comparator</code> is imported from <code>(srfi
146)</code>, it provides a (partial) ordering predicate that is
applicable to pairs of mappings with the same (key) comparator.
If <code>(make-hashmap-comparator)</code> is imported
from <code>(srfi 146 hash)</code>, it provides an
implementation-dependent hash function.
</p>

<p>If <code>make-mapping-comparator</code> is imported from <code>(srfi
Expand All @@ -1227,9 +1221,10 @@ <h2 id="Comparators">Comparators</h2>
the ordering of the values) is used for mappings sharing a comparator.
</p>

<p>
When ordering mappings with different comparators, they are ordered
by the default ordering of their comparators.
<p>The existence of comparators returned
by <code>make-mapping-comparator</code> allows mappings whose keys
are mappings themselves, and it allows to compare mappings whose
values are mappings.
</p>

<p>
Expand Down

0 comments on commit 5acad4b

Please sign in to comment.