| Ilya Zakharevich on Tue, 16 Jan 2024 05:22:12 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Bizarre semantic of vecsearch/setsearch |
First, setsearch()/vecsearch() are just three flavors of the same function
(since setsearch() has 2 flavors ;―]). — But the documentation of neither
of them mentions the other one.
Second, these 3 flavors seem to be kind of inconvenient: in the
contexts I have in mind¹⁾, what seems more reasonable are
• Return the largest index with the value < argument.
• Return the largest index with the value ≤ argument.
• As above, but mark the case when the value = argument.
(E.g., in the last case, one can return negative index on
equality. — Works since this index is never 0.)
¹⁾ Find the intersection of the list with an interval [b,c]. (And,
since these b and c are variable, I need to know “where exactly
is the intersection” if empty.)
⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜⁜
It seems that these extra semantics have 0 runtime cost.
It would be nice if these semantics were implemented. However, since
the current 3 implemented semantics are split between two function
names, I would be very puzzled on WHERE to put these flavors…
For the last flavor above, it would seem natural to trigger this by a
negative flag — but due to the docs beings too permissive, this is not
backwards compatible. (Do not know whether such “improbable”
incompatibilities are considered permissible…)
Thanks,
Ilya