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

buildFrom methods return a copy instead of a reference or void #1353

Open
SamFlt opened this issue Mar 18, 2024 · 1 comment
Open

buildFrom methods return a copy instead of a reference or void #1353

SamFlt opened this issue Mar 18, 2024 · 1 comment

Comments

@SamFlt
Copy link
Contributor

SamFlt commented Mar 18, 2024

Many classes in ViSP have a standard buildFrom method, which serves as a delayed constructor/initializer.

In many classes, this method has the signature vpObject buildFrom(Args... args). However, buildFrom modifies the calling object and there is very little sense in returning a copy.

This method should either:

  • Return void: this method acts as a setter
  • Return a reference: Allows for method chaining e.g. x.buildFrom(args).compute();

Currently, we can perform method chaining, but this is misleading

Some of the affected classes are:

  • vpRzyxVector, vpRxyzVector, vpRzyzVector
  • vpThetaUVector
  • vpQuaternionVector
  • vpRotationMatrix
  • vpTranslationVector
  • vpPoseVector
  • vpVelocityTwistMatrix
  • vpForceTwistMatrix
@fspindle
Copy link
Contributor

We could make all the buildFrom() deprecated and introduce new functions vpObject &build(Args... args)

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

2 participants