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

u_str macro #14

Open
bc0n opened this issue Nov 21, 2024 · 0 comments
Open

u_str macro #14

bc0n opened this issue Nov 21, 2024 · 0 comments
Assignees

Comments

@bc0n
Copy link
Member

bc0n commented Nov 21, 2024

How does this work in Unitful and DynamicQuantities?

  • I need to be able to look up a unit type from the unit label, but since these are not 'registered' with the package do I have to search the type tree?
    No, if I make the the unit labels into functions, I can just blindly call the label-function: 3u"mm" -> "mm" -> mm(1) -> 3*mm(1).
    Since */-^ are not valid function identifiers, I can't make literal label-functions for complex units like Kg-m/s^2. Instead I need to insert logic into u_str to break that into atomic label functions and return Kg(1)*m(1)/s(1)^2.

  • How does u_str() work?
    With a little magic; simply defining a macro u_str(arg) leads to the correct handling of 3u"mm", there must be some internal stripping of _str and parsing of 3u"mm" into 3 * (return of macro u_str("mm")).

@bc0n bc0n self-assigned this Nov 21, 2024
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

1 participant