Really expose range-indexer?
Marc Nieper-WiÃkirchen 31 Aug 2020 18:35 UTC
In the description of range-indexer, it says: "Returns the indexer of
range. This procedure must run in O(1) time."
What is "the" indexer? I guess at least the following should be true:
(eq? ((range-indexer range) i) (range-ref range i))
But a few more guarantees may be intended to hold:
(eq? (range-indexer range) (range-indexer range))
or
(eq? (range-indexer (range n indexer)) indexer)
However, these further guarantees can be problematic for range
constructors like range-append (which could create the needed indexer
on the fly).
As it is not clear to me what is a good use case of range-indexer
after all, I would consider dropping the procedure. And if you don't
want to drop it, I would explicitly remove the "the" and just
guarantee the first property for the sake of extensibility of the
range API. Otherwise, we expose too much implementation detail.
Marc