rust-lang / libm

A port of MUSL's libm to Rust.
Other
547 stars 97 forks source link

Migrate types from a macro to a trait #349

Closed tgross35 closed 2 weeks ago

tgross35 commented 3 weeks ago

This allows us to move a lot of logic out of macros and into generic functions, which is a nice cleanup and much better for usability.

tgross35 commented 3 weeks ago

@beetrees I'm still working on some better naming cleanup / docs / comments, but you may want to take a look at this. Basically migrating from always relying on macro expansion to putting everything into a trait, which should help avoid string matching problems (like you pointed out on a different PR).

None of the possible refactoring of ULP / precision is done here.

tgross35 commented 3 weeks ago

Let me know if you have any name suggestions too. I feel like too much here is some variation of "function" or "op", but I can't come up with anything much better.

tgross35 commented 2 weeks ago

I still don't have great names but I added the following to hopefully disambiguate a bit https://github.com/rust-lang/libm/blob/7c418306c90bf0180249b3f38761e416cfee86a9/crates/libm-test/src/op.rs#L6-L14

beetrees commented 2 weeks ago

I think the naming here is always going to be somewhat arbitrary, but I think what you've gone with is perfectly reasonable terminology (I don't have any unequivocally better ideas). The most important thing (which I can see you have done) is to make sure it's documented.