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

Java Unit types missing mult(U) functions #7156

Open
bhall-ctre opened this issue Oct 3, 2024 · 2 comments
Open

Java Unit types missing mult(U) functions #7156

bhall-ctre opened this issue Oct 3, 2024 · 2 comments
Labels
component: wpiunits Java units library type: fix Iterations on existing features or infrastructure.

Comments

@bhall-ctre
Copy link
Contributor

bhall-ctre commented Oct 3, 2024

It looks like all the Java unit types have per(U) functions, but many of them are missing generic mult(U) functions. For now, users can use MultUnit.combine(a, b), but it would be nice if users could directly do something like Volts.per(Rotation.mult(Second)) for all units (as I believe was the case with 2024 units).

@SamCarlberg
Copy link
Member

So, a caveat to this is type erasure (of course) with combinatory units and their subclasses. Something like this wouldn't be possible:

public class Per<N extends Unit, D extends Unit> extends Unit {
  N mult(D denom) { ... }

  <Other extends Unit> MultUnit<? extends Per<N, D>, Other> mult(Other other) { ... }
}

Because N and Other both erase down to Unit and result in identical method signatures

But basic non-combinatory types like voltage and angle should be fine. My main concern would be lack of consistency, like having only some units support mult while others don't or only in a limited way.

@bhall-ctre
Copy link
Contributor Author

Given that mult() and per() are both used moreso to create new units rather than to perform dimensional analysis (which is more what I would expect from times() and divide()), I think that's a fair trade-off. MultUnit.combine(a, b) already doesn't do any dimensional analysis either.

@auscompgeek auscompgeek added the component: wpiunits Java units library label Oct 6, 2024
@calcmogul calcmogul added the type: fix Iterations on existing features or infrastructure. label Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: wpiunits Java units library type: fix Iterations on existing features or infrastructure.
Projects
None yet
Development

No branches or pull requests

4 participants