-
Notifications
You must be signed in to change notification settings - Fork 0
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
Units from declarative macro instead of manually coded definitions #24
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Also adds a CT table storing all the quantities generated.
This moves all the unit parsing logic into a separate module (not used as of this commit)
All units are now defined using a declarative macro. All logic is built on that. This means it should (gotta try first to know, huh?) now be trivial to define other unit systems etc. by just replacing the declarations.
Provide a debug message if compiled with -d:debugUnits
Instead we now simply depend on the fact that all units are defined on top of our known distinct types. We simply resolve until we find a known distinct or nothing.
`api.nim` imports and exports the whole user facing API. `ct_api` as the name suggests provides the compile time API to declare quantities and units.
`^` nowadays lives in `utils`
This is just to showcase how one defines custom quantities and unit systems.
we install cairo via msys2 like in ggplotnim
For some reason in CI in this repo lapack isn't found using msys2. But it works fine in ggplotnim using the same approach. Weird.
This was referenced Jul 27, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Further progress towards #8.
After cleaning this up (especially the duplicated parsing logic & partially duplicated types in main & for definition), we are essentially ready to replace most of the current logic based on
UnitKind
etc. by a more type aware logic based onDefinedUnit
elements. This will significantly clean up how individual units are added and maintained.edit: making good progress...
edit 2: it is done.
With this now complete, #8 should essentially be solved now. This means in theory we can define any unit system as follows:
So feel free to define the CGS or whatever you please.