Bart wrote, On 01/12/07 12:27:
To me &x is easier to read and conveys more information; x by itself
could be anything, while &x is likely (in a function with 'get' in the
name) to be a reference to some data destination.
Ah, but &x is a different type, hence the cast in the above code. The
cast prevents the compiler from telling you if x is actually an array of
doubles, so incorrectly using &x and then casting to "fix it up" makes
your program more fragile.
C seems to have a somewhat arbitrary distinction between variables
that can be passed by value, and variables that can only be passed by
reference
It is not an arbitrary distinction. The problem is that you do not yet
know how C works, which is that *everything* is always passed by value.
(arrays and structs, even if they are only as big as an int
for example).
structs to not even give the appearance of being passed by reference,
unlike arrays.
Although it's never going to happen now, if arrays and structs were
ever allowed to be passed by value, then all those missing &'s are
going to be a problem!
Structs are *always* passed by value. Well, you can pass a pointer to a
struct, but that is done differently.
So allowing this kind of lazy coding (letting x and &x mean the same
thing
-- sometimes!) may well have impeded development of the language.
Again you do not understand the language. x and &x always mean different
things and the only time they give a real appearance of meaning the same
thing is when & is applied to a function name, in which case the
distinction is academic.
In most instances the name of an array decays to a pointer to the first
element of the array. &array_name give a pointer to the array, i.e. a
different type.
For more information on this read the comp.lang.c FAQ starting with
section 6. You can find the FAQ at
http://c-faq.com/