(e-mail address removed) said:
You mean like you should never comment your code because comments are
superfluous?
I don't agree that comments are superfluous. *You* said the structure was
superfluous, and "superfluous" means "redundant, unnecessary" (look in a
dictionary if you don't believe me).
(Certainly, their value is at best subjective.)
Sometimes redundancy is useful -- this is the lesson of structured
programming.
If it's useful, how can it be redundant?
Sure. Self-modifying code works fine too.
In my experience, such code nails you pretty firmly to a particular platform
(or group of closely-related platforms).
But taking a step back, it occurrs to me that "it works fine" is
a fairly low standard for writing code.
Taking a step forward again, "it works fine" is a fabulous *baseline* for
writing code. For example, fopen works fine, and I use it quite happily,
without worrying that my code is somehow of a low standard just because it
uses something that works fine. Using void pointers correctly does not
imply fragile code. Using void pointers incorrectly is a losing strategy.
But so is using casts incorrectly. So is using fopen incorrectly. So is
using *anything* incorrectly.
On the counter point, have you ever tried to debug a messed up type
coercion hidden by a void *?
Yes - in fact I've almost certainly done so right here in comp.lang.c. And
I've debugged screwed-up macro calls, too. So?
The real problem with it is that you
don't even realize that's what's gone wrong until you get deeply into
debugging in. And the debugger will typically be far less helpful than
you wished.
"Think first, compute later" is always a good plan. I generally don't bother
too much with debuggers nowadays. They are occasional ports in a storm,
that's all.
[...] It can hide the non-inclusion of it's prototype,
On *SOME* older generation compilers. No modern compiler fails to
give a warning about this regardless of the cast.
So if anyone comes up with a counter-example, you can simply claim
that it's not a "modern" compiler. ("True Scotsman" argument.)
For development?
Sure. Just because an implementation doesn't give one particular
diagnostic message that Paul Hsieh thinks it should, that doesn't mean
it's a Bad Compiler.
Right ... but we're several posts into this, and you couldn't even come
up with one?
Why bother? The diagnostic message is not required by the Standard, so it
makes no sense to me to insist to compiler-writers that they provide it. In
general, I use the compiler I'm given when on client sites. If I were to
say to a client, "Paul Hsieh suggests we use a different compiler to the
one you've been using quite happily for this whole project and many others
before, because this one doesn't diagnose <foo>, which it isn't required to
by the Standard", he'd laugh in my face, and rightly so.
"idiotatic"? Okay, let's assume you mean "idiotic". It is your right to hold
that opinion, but your saying that use of void * is idiotic doesn't make it
so.
[...] So trying to make C type safe is a bit like
trying to make Ook! object-oriented.
Interesting observation. If you intersect C and C++ what are you left
with?
Either poor C, poor C++, or syntax errors.
Well to some people type safety is free automated assistance.
I have no problem with free automated assistance, but free automated
dictation is another matter. Whether a pointer of type <foo> is meaningful
Do I smell a fundamentalist ideology?
No, you smell comp.lang.c, which is about C, not C++. If you want to discuss
C++, there's a whole nother newsgroup for that. And if you want to discuss
programming in general, there's a newsgroup for that, too.
I don't know what you are talking about. You cut and paste, you change
the target variable and miss the sizeof variable.
Oh, okay, I see what you mean. I thought you were talking about types, not
objects. The reason I didn't "get it" immediately is probably because I
find it quicker to type p = malloc(n * sizeof *p); than to invoke a copy
operation, a move operation, a paste operation, and two edits. Copy-paste
is expensive compared to typing when the amount to be copied is low, and
silly when the amount to be copied is high (because you're missing an
opportunity for re-factoring).
Ok, you've just
introduced a silent error, that's many hours of debugging waiting to
happen.
Perhaps I need more practice. I generally don't manage to make debugging
last more than a few minutes.