-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
which APIs need to be public/private #30
Comments
Yeah I definitely agree on the principle.
Yes, fortunately :) We may discuss the details in PRs later, but please feel free to update the interfaces as you like. |
Taking your comment from the merged PR #32 so we can discuss it more here:
I tried doing that but it's not that simple: Since I tried quite a few modifications to make that go away, but it's pretty fundamental. I think the way forward may have to be the following:
After this I think we can hide the internal traits as they're for implementation purposes only. There are still potential issues I haven't figured out yet: the I really hope there's a simpler way to do accomplish this but I haven't figured it out yet! I hope you have some ideas. |
For simplicity, I think we can merge
I guess we can consider the merged trait as the internal trait you mentioned (
Regarding names, another idea would be renaming |
I'll play with this a little, see where we end up. I am not sure "Default" is the right naming, but I'll experiment a little and see whether we can come up with an obvious next step. |
Thanks! I also made a draft that implements the idea #36. |
I think we've made a lot of progress here! There's one remaining question whether we want to promote The simplest step is to make public We can't hide |
While I was working on API documentation I ran into some APIs that are currently public but I think should be private or sealed. There are technical challenges in this, I'll go into that in the end. Another solution is to simply eliminate some of these traits
Here's a list:
in
suffixarray
:IndexWithSA
- this allows the index to construct the location forlocate
queries. But it's really internalPartialArray
- is used inget_sa
(see previous) and in Debug andsize
methods internally. The only implementation isSuffixOrderSampledArray
so functionality could be merged into it.ArraySampler
trait - could be sealed as it's really only used internally to supportNullSampler
andSuffixOrderSampler
.in
character
:Character
is exposed. I think it should be but I think it could be sealed as we don't expect anyone to implement these externally? Or perhaps we do - make a custom enum into a character, for instance?in
iter
:BackwardIterableIndex
andForwardIterableIndex
are currently public traits which are exposed, but they really expose implementation details. Could we make them entirely private? If not, we could seal them entirely, hiding their methods and making it impossible to implement them.We may be able to hide
BackwardIterator
andForwardIterator
too if we make the methods return animpl Iterator
instead.In
search
BackwardSearchIndex
is automatically implemented for everything that has aBackwardIterableIndex
. So maybe we can simply makesearch_backward
a default method onBackwardIterableIndex
?The technical challenges have to do with how some of these details are used; if I make them
pub(crate)
for instance I get complaints that I'm making somethingpub
that depends on something more private. I think some refactoring is required to make it possible to hide these traits. I haven't delved into this yet but we may want sealed traits. This looks like a useful overview of this pattern.My goals are more clear than how we accomplish them: expose a compact API surface to end users, and preferably make the traits internal only. Since I don't think many people use this trait, I think we are free to break compatibility without consequences at this stage.
So do you agree with this general goal? If so, I will try to find some time to work on it, or we can collaborate - I feel confident I can figure this out myself, unlike some of the other issues.
The text was updated successfully, but these errors were encountered: