-
Notifications
You must be signed in to change notification settings - Fork 155
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
condensed duplicate code for trait specialization using macros #424
base: master
Are you sure you want to change the base?
condensed duplicate code for trait specialization using macros #424
Conversation
ping! @brendanzab have any thoughts on this one? I mainly did it because the first PR I submitted failed on the simd travis builds the first time, and I had to fix it by duplicating code. Doing it this way means that changes to the trait implementations only need to happen in one place, so it should reduce friction on future patches |
Woopsie, sorry I looked, thought it was awesome, then forgot to reply! Yeah, I re-read the simd stuff a while back and got a tad confused. In fact I think a whole lot of our macro stuff is a bit ugly, so I'm glad you've been looking into it! |
@@ -17,102 +17,148 @@ | |||
|
|||
#![macro_use] | |||
|
|||
/// generates an impl fn, allowing specialization if simd is enabled | |||
macro_rules! impl_fn { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think I'd prefer this called impl_operator_method!
/// generates an impl fn, allowing specialization if simd is enabled | ||
macro_rules! impl_fn { | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra space here!
these changes are in my queue. will probably get to it in the next few days |
@hclarke looks like the few days got stretched quite a bit :) |
I put all the "default" keyword stuff into a impl_fn! macro. that way, there's way less duplicate code for simd trait implementations
I also feel like there should be a "specialization" or "nightly" feature that's separate from "simd" (that simd enables/depends on). This patch doesn't include that, but makes it easier to implement, since there's only one macro to change
also made a BaseSigned trait so that you can use the trait implementation macros for Neg