Skip to content
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

Stabilize and document static dispatch interface #34

Open
reinerp opened this issue Jul 19, 2022 · 1 comment
Open

Stabilize and document static dispatch interface #34

reinerp opened this issue Jul 19, 2022 · 1 comment

Comments

@reinerp
Copy link

reinerp commented Jul 19, 2022

For some libraries I'm writing, I'd like to provide multiple versions of my functions with support for static dispatch, but I don't want to take a dependency on syn, and therefore also no dependency on multiversion. However, I'd like to allow my users, some of whom are willing to depend on multiversion, to benefit from static dispatch when calling into my library.

Would it be possible to stabilize the static dispatch interface, and document it, so that I can manually provide functions that are available to multiversion's static dispatch?

@calebzulawski
Copy link
Owner

calebzulawski commented Jul 29, 2022

I'm actually working on some fairly large changes, one of which will entirely remove the static dispatch API. Without getting into too much detail, the static dispatch implementation relies on some hacks that are not flexible and have some bad edge cases.

I'm not sure how useful it will be in your particular use case, but the new version will provide some sort of const feature object, that will allow you to do something like

if FEATURES.supports("avx") {
    call_avx_fn()
} else {
    call_default_fn()
}

While more verbose than the existing static dispatch, I believe this should allow conditionally selecting code (not just functions!) at compile time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants