← Back to team overview

yade-dev team mailing list archive

ScGeom->rotate takes reference arg and returns reference

 

Hi (Bruno),

ScGeom->rotate changes the argument it receives in-place and returns
reference to it. I think the return is unnecessary and misleading. E.g.
code reading

Fs=geom->rotate(Fs);

leads to updating Fs (via the reference), which is then written back over
itself (the return value); writing geom->rotate(Fs) will do the same thing,
and a little faster.

Further, if one misses the fact that the argument is a reference, one
might end up with the same variable changed several times. Usually
functions either have side-effects and return void, or have no side-effects
and just compute the return value; that prevents such confusion. (Cf.
normalize() in eigen which does not return the norm, since it changes the
object as well, unlike Normalize() in wm3).

Would you agree that I change it to return void?

Cheers, v.