Re: C : Call by value or reference
On Sun, 15 Jul 2007 17:56:12 +0000, CryptiqueGuy wrote:
^^^^^
What happened to 'r'? :-)
>
Both your declarations follow pass by value. What is there in it?
Absolutely nothing.
But if foo2 is called as foo2(&someth) and its definition dereferences
ptr, foo2 is able to access a variable local to its caller, which foo1
will never be able to do (unless the struct contains pointers and foo1
dereferences them.
--
Army1987 (Replace "NOSPAM" with "email")
"Never attribute to malice that which can be adequately explained
by stupidity." -- R. J. Hanlon (?)
On Sun, 15 Jul 2007 17:56:12 +0000, CryptiqueGuy wrote:
On Sun, 15 Jul 2007 13:22:52 +0000, Richard Heathfield wrote:
>>
>>C is a 100% call-by-value language. Function arguments are
>>expressions ,
>>not objects. These expressions are evaluated, and those values are
>>passed to the function.
This statement is not wrong but highly misleading. Esp. it doesn't
cover the distinction between the following:
>>expressions ,
>>not objects. These expressions are evaluated, and those values are
>>passed to the function.
This statement is not wrong but highly misleading. Esp. it doesn't
cover the distinction between the following:
void foo1 (stuct something sth);
void foo2 (stuct something* ptr);
void foo2 (stuct something* ptr);
What happened to 'r'? :-)
>It's all "words". I suspect the OP was looking for pointers - which
>also makes me wonder if he is a troll. Since how can he implement a
>garbage collector and not either (a) know the answer or (b) know how to
>google up the answer.
>also makes me wonder if he is a troll. Since how can he implement a
>garbage collector and not either (a) know the answer or (b) know how to
>google up the answer.
Both your declarations follow pass by value. What is there in it?
But if foo2 is called as foo2(&someth) and its definition dereferences
ptr, foo2 is able to access a variable local to its caller, which foo1
will never be able to do (unless the struct contains pointers and foo1
dereferences them.
--
Army1987 (Replace "NOSPAM" with "email")
"Never attribute to malice that which can be adequately explained
by stupidity." -- R. J. Hanlon (?)
Comment