-
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
Use macro to reduce code duplication #3
Comments
Tried out using macros to reduce some boilerplate recently. They helped reduce test code and trait implementations, but when using them for inherit methods they messed the documentation up a bit too much for my liking, so I copied the inherit methods back to each type for now. So far this way of doing things works well enough, although the tests macro should be modified slightly to allow for tests that can only be done by certain types. |
Right now the code between
r32
andr64
is pretty much the same (as a result of copy-pasting it) except for some modifications to handle larger numbers inr64
. Ideally tho, there should be a macro that handles implementations for both types in order to reduce code reuse and possible inconsistencies between them.Such a macro should only rely on:
TOTAL_SIZE
– gives the total number of bits of the internal type; e.g. forr32
, it's 32 bits (note: not currently defined in code)FRACTION_SIZE
– gives the size of the fraction fieldEverything else (including other necessary constants) should be derivable from the ones above.
The text was updated successfully, but these errors were encountered: