Skip to content

Conversation

@Gold856
Copy link
Contributor

@Gold856 Gold856 commented Oct 3, 2025

No description provided.

@Gold856 Gold856 requested review from a team as code owners October 3, 2025 22:25
calcmogul
calcmogul previously approved these changes Oct 3, 2025
@Gold856 Gold856 force-pushed the immutable-swervemodulestate-functions branch 2 times, most recently from b5cc719 to 994050e Compare October 3, 2025 23:38
@Gold856 Gold856 force-pushed the immutable-swervemodulestate-functions branch from 994050e to 80c5438 Compare October 4, 2025 00:59
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more consistent if SwerveModuleState and SwerveModulePosition were entirely immutable, i.e final speed, angle, and distance properties, along with withX() member functions

Copy link
Member

@calcmogul calcmogul Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're still modifying specific members directly with no invariants to maintain (e.g., via withX()), then member function access is just more boilerplate for no gain. Spawning another object on top of that is just needlessly wasteful.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why make the other functions immutable then?

Copy link
Member

@calcmogul calcmogul Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Member variable mutation is easier for the reader to notice when done directly than when member functions do it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, makes sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants