And I thought that, while & references seem to be a C++ concept, it
was useful to point out that they might be available on at least some
C implementations, obviously as an extension.
I think it's also useful to have a broader perspective on this sort of
thing, because it helps in understanding some of the conceptual problems
people sometimes have with C.
Parameter passing in C is beautifully simple: everything is passed by
value, and if you need to do what other languages call "pass by
reference", you just pass a pointer and modify the object through that.
In languages like Java, the situation is a mess. Pretty well everything
is passed as a reference, except certain "built in types" like int and
double, which are usually passed by value. But at least you can learn,
for each type, how it will be passed.
C++ is even worse, because if you see code like
int foo = 42;
bar(foo);
assert(foo == 42);
then you have no way of knowing whether the assert will succeed without
looking at the prototype of bar() to find out whether it just takes an
int or a reference to an int. In my opinion, this is horribly confusing,
especially when bar() is some sort of overloaded method in a multiply
inherited class or whatever, and it's hard to find out what the hell is
actually going on.
On the other hand, passing things by constant reference in the public
interface of a class is such a well-established idiom in C++ that it's
hard to avoid running across it.
So it's perfectly natural for people to wonder what the differences in
argument passing are in C compared to other languages, and why shouldn't
they ask about it here? If they want to crosspost to another group, then
that's fine too.