D
Dave Thompson
Aside from the typo and the fact that the conventional term is white``C treats all blanks space as equivalent, so line breaks
and indents are for readability only.''
So #define FOO 10
is the same as #defineFOO10 ?
space or whitespace, with no comparand (or whatever it's called) this
can only be read as meaning one whitespace is equivalent to another
whitespace, which is correct except for preprocessor and literals; it
is not reasonable to read it as saying whitespace is equivalent to an
empty string. So a better counterexample is
#define FOO 10
#define FOO
10
or "this is a string" "this\tis\na string"
(points I more-or-less agree with snipped)
which is of course silly anyway, unless i actually (expands to``More generally, array[n] is equivalent to *(array + n) and in
fact is defined as such.''
No it isn't. It is equivalent to *((array) + (n))
The added parens are important. If your method
was actually used then the following would
fail:
a[i, j];
something that) has (relevant) side effects
No it wouldn't; given a is an array or pointer, a[i,j] is legal onlyWhich would be equivalent to *(a + i, j)
Which would end up dereferencing the value of ``j''
as opposed to *((a) + (i, j))
if j is an integer type, in which case *(a+i,j) is a constraint
violation. I don't see any case *of this particular transform* where
extra parens are needed, although it wouldn't hurt to use them to
emphasize/clarify the atomicity of the components.
``int array[20];
for (i = 0; i < 20; i++)
{ { code involving array; } }''
``i < sizeof array / sizeof array[0]''
is the more common convention
In this newsgroup it is, but IME not universally; a #define or
possibly enumerated value used in both places is also common, and
(sadly) so are magic numbers.
It is more automatically/robustly safe, especially when packaged in a
macro, and especially if you add one of the clever tricks to error out
on a pointer, and might better be promoted on those grounds.
But you may want to cast it to signed, or make i unsigned, for those
@#* compilers that warn noisily about comparing signed to unsigned.
- David.Thompson1 at worldnet.att.net