Re: Re-use the argument?
- From: Richard<rgrdev@xxxxxxxxx>
- Date: Sun, 08 Jun 2008 20:07:24 +0200
"Malcolm McLean" <regniztar@xxxxxxxxxxxxxx> writes:
"Richard" <rgrdev@xxxxxxxxx> wrote in message
"Malcolm McLean" <regniztar@xxxxxxxxxxxxxx> writes:
"Tomás Ó hÉilidhe" <toe@xxxxxxxxxxx> wrote in message news:
Generally it is considered bad form to modify an argument to a
Which of these functions would you go with?
unsigned Func(unsigned const x)
{
return 3*x - 2;
}
or:
unsigned Func(unsigned x)
{
x *= 3;
x -= 2;
return x;
}
function. It makes things a bit more difficult to read.
What a load of nonsense. If its not a const its no more than a local
variable.
There's a previous thread on the subject
Newsgroups: comp.lang.c
From: Morgan Cheng <mo...@xxxxxxxxxxxxx>
Date: Tue, 19 Jul 2005 09:41:26 +0800
Local: Tues, Jul 19 2005 2:41 am
Subject: Should function argument be changed in function body?
I think this link should lead to it
http://groups.google.com/group/comp.lang.c/msg/3ac943f1b7a6c3c5
I really am not interested in that. Its effectively a local variable and
I have never seen anyone object, in the real world, to it being
manipulated. e.g it might be a date representing a proposed day for a
task. I would see no issue with updating the parameter to a new more
suitable date and then returning it. Still, all to their own as they say.
.
- Follow-Ups:
- Re: Re-use the argument?
- From: Richard Tobin
- Re: Re-use the argument?
- References:
- Re-use the argument?
- From: Tomás Ó hÉilidhe
- Re: Re-use the argument?
- From: Malcolm McLean
- Re: Re-use the argument?
- From: Richard
- Re: Re-use the argument?
- From: Malcolm McLean
- Re-use the argument?
- Prev by Date: Re: printing effort
- Next by Date: Re: Pointer to qualified poitner to qualified object
- Previous by thread: Re: Re-use the argument?
- Next by thread: Re: Re-use the argument?
- Index(es):
Relevant Pages
|