Skip to content

[wpimath] Make Java take lists instead of Vectors where C++ takes wpi::arrays #7826

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

Open
calcmogul opened this issue Feb 25, 2025 · 6 comments
Labels
2027 2027 target component: wpimath Math library

Comments

@calcmogul
Copy link
Member

A lot of wpimath Java APIs take a Vector<N> type, but VecBuilder.fill(...) is more verbose than List.of(...).

@calcmogul calcmogul added this to 2027 Feb 21, 2025
@calcmogul calcmogul converted this from a draft issue Feb 25, 2025
@calcmogul calcmogul added component: wpimath Math library 2027 2027 target labels Feb 25, 2025
@PeterJohnson
Copy link
Member

Doesn’t that require boxing? You can’t have a List<double>, only a List<Double>.

@calcmogul
Copy link
Member Author

calcmogul commented Feb 25, 2025

The Vector<N> type requires boxing anyway.

@PeterJohnson PeterJohnson moved this to Backlog in 2027 Apr 18, 2025
@auscompgeek
Copy link
Member

Would it make sense for any of them to take primitive arrays instead?

@calcmogul
Copy link
Member Author

calcmogul commented Apr 21, 2025

Depends on whether we like new double[]{ ... } better syntax-wise. It's not terrible to type, and it doesn't require a random import like Vector<N> does.

@KangarooKoala
Copy link
Contributor

KangarooKoala commented Apr 22, 2025

Just to help for comparison:

// Vector
foo(VecBuilder.fill(1.0, 2.0, 3.0));
// List
foo(List.of(1.0, 2.0, 3.0));
// Array
foo(new double[] { 1.0, 2.0, 3.0 });

@wpilibsuite wpilibsuite deleted a comment from KangarooKoala Apr 22, 2025
@calcmogul
Copy link
Member Author

calcmogul commented Apr 22, 2025

The second one is shortest and is likely more familiar due to it using a standard Java container, but knowing the correct import is still an issue (java.util.List). The third one requires no imports, but the syntax is rather arcane. Neither are my favorite, but I'd accept either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2027 2027 target component: wpimath Math library
Projects
Status: Backlog
Development

No branches or pull requests

4 participants