Hiding default implementations in refinements #1624
dabrahams
started this conversation in
Language design
Replies: 1 comment
-
What if we just repeat the requirement in
Since there is no way in general to check that a particular implementation has O(x) complexity, we can only rely on the user to satisfy the semantic requirement that's documented in This setup makes it possible to write the following, assuming
There may be some complications with the way we can create the most refined witness table but I don't have any obvious showstopper on the top of my head. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was working with this design
Now when you get to
RandomAccessCollection
, you really want to requiredistance
andposition
to be reimplemented in O(1). The topic raised is whether we need a feature to hide the defaults.An alternative I thought of was :
I don't love that because
q
-p
might sometimes be faster than(q - start) - (p - start)
, e.g.p
andq
are in the same segment of aDeque
. That's minor but real. If we classified something with pseudolinear traversal like a B-tree as random access it might get real-er.Beta Was this translation helpful? Give feedback.
All reactions