Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a second attempt at #563, but using the C bindings as the basis for Swift interop, rather than the C++ interface. This adds a layer of indirection, but drastically simplifies the interop types. Given that Swift/C++ interop is not yet capable of expressing the necessary types for USearch, this is a better option to split the Objective-C and Swift codebases, and ultimately, to support Swift on Linux.
What's changed
clear
method was missing, and it would be better to remain mostly API compatible.usearch_c
module, backed by the C implementation.What's not changing
Other than the necessary introduction of throwing functions (remember that the Swift interface currently cannot handle any errors at all, they explicitly crash the application), there are no API changes to the high-level "Sugar" interface. Additionally the tests do not change, other than to support thrown errors.
For most projects this upgrade should be a straightforward process of adding
try
s to calls and handling errors. Most production users probably already wrap the Swift interface in Objective-C to be able to catch exceptions, and can therefore simplify their code significantly.Future improvements
These are purposefully left out of this implementation to keep it manageable and reviewable.
MainActor
so that there is a guaranteed single instance, and internally manage the number of in-flight requests to the index up to the limit of the number of threads.