Re: Re-use the argument?



Richard Tobin said:

<snip>

The key is to be clear.

No argument there - I'm just nit-hunting right now.

For example, consider
a function to determine kinetic energy given mass and speed:

You can't. You need the velocity, not the speed.

double ke(double mass, double speed)
{
return mass * speed * speed;
}

....and you also need another trifling ingredient...

double ke(double mass, double velocity)
{
return mass * velocity * velocity / 2.0;
}

For excruciatingly exact nit-picking, you could also accept, and multiply
by, a parameter that represents the constant of proportionality required
to make the equation work in a given system of units (whether it be SI,
cgs, Imperial, or whatever).

<good stuff snipped, quick summary retained below>

So I don't think there's a special rule for re-using argument
variables. You should just apply the same reasoning you would for any
variable: does it make sense to use this variable for this purpose?

Right.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
.



Relevant Pages

  • Re: photon animation
    ... that the means to obtain the mean orbital velocity for any mean ... orbital distance is you use the basic for force and work, ... This is also the fundamental of 1/2mv^2, or kinetic energy. ... mass x acceleration or mass x (final velocity - intitial velocity/ ...
    (sci.physics)
  • Re: A CHALLENGE
    ... The core of the endeavor to reconcile the kinetic energy of an ... with the sub c velocity of the latter. ... what is the velocity of the ponderous particle? ... oscillations and m_q the mass of each oscillation ...
    (sci.physics.relativity)
  • e NOT EQUAL TO mc2
    ... to a velocity v is of course, ... from the relation between velocity and kinetic energy being non-linear. ... momentum which equals mv and not kinetic energy. ... move a 2 kg mass through one metre than it would the same force to move ...
    (sci.physics.relativity)
  • Re: Propellantless propulsion fun 3 (recirculative propelant)
    ... where m is whatever mass is involved. ... calculating the kinetic energy going to accomplish ... mass and the square of the velocity. ... frame dependent. ...
    (sci.physics)
  • Re: Propellantless propulsion fun 3 (recirculative propelant)
    ... where m is whatever mass is involved. ... calculating the kinetic energy going to accomplish ... mass and the square of the velocity. ... will violate the conservation of energy. ...
    (sci.physics)