Re: Re-use the argument?
- From: Richard Heathfield <rjh@xxxxxxxxxxxxxxx>
- Date: Mon, 09 Jun 2008 07:39:44 +0000
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
.
- Follow-Ups:
- Re: Re-use the argument?
- From: Nick Keighley
- Re: Re-use the argument?
- From: Richard Tobin
- [ot]Re: Re-use the argument?
- From: pete
- Re: Re-use the argument?
- References:
- Re-use the argument?
- From: Tomás Ó hÉilidhe
- Re: Re-use the argument?
- From: Richard
- Re: Re-use the argument?
- From: Malcolm McLean
- Re: Re-use the argument?
- From: Richard
- Re: Re-use the argument?
- From: Richard Tobin
- Re-use the argument?
- Prev by Date: Re: A CT&P excursion - beat it up!
- Next by Date: Re: A CT&P excursion - beat it up!
- Previous by thread: Re: Re-use the argument?
- Next by thread: [ot]Re: Re-use the argument?
- Index(es):
Relevant Pages
|