Re: Segfault City




Andrew Poelstra wrote:
On 2006-06-24, spinoza1111@xxxxxxxxx <spinoza1111@xxxxxxxxx> wrote:

Andrew Poelstra wrote:
On 2006-06-24, Richard Heathfield <invalid@xxxxxxxxxxxxxxx> wrote:
[X-posted, and followups set]

I found something interesting on the Web today, purely by chance.


Just out of curiousity, did you stumble upon that while Googling your own
name? I'm not accusing you of arrogance, but it's interesting that he
mentions and insults you specifically in his preamble.

It would be funny if it weren't so sad. Or sad if it weren't so funny. I'm
not sure which.

http://www.developerdotstar.com/community/node/291

This "teacher of C" demonstrates his prowess with a masterful display of
incompetence in a 200-line program that travels as swiftly as possible to
Segfault City.


Ooh. Segfault City. Where all bad programs go to die. :-)

(Actually, using my normal gcc switches, it doesn't even get past TP3, but
it will at least compile if you just use gcc -o foo foo.c, after hacking it
around a bit to do things like mending the line-spanning single-line
comments and string literals, which - in fairness to the author - are
probably an artifact of the Webification of the code.)

I wonder how long I'll take to stop laughing.


I stopped reading after the first function. I wasn't sure why he kept

Which disqualifies you from a technical discussion. Why are you
posting?


How does that disqualify me? I read through an entire function that could be
replaced with... let's see... 4 characters: -'0'. That's a lot more tolerance
than a lesser programmer might have. Why on earth would you use a function at
all?

What is simpler?

n = c - '0';

or

n = char2digit (c);

The question isn't what is "simpler". Your obvious preference FAILS if
c > '9' or < '0' without any indication of failure, and correctness
lexically precedes efficiency .


The former is a well-known construct. The latter is a function call that looks
exactly like any other function. One of them I can glance over and see what it
does, while the other requires me to stop and look.

They both require checks if you want to ensure that c is a digit. It's just
that's one's shorter, simpler and more efficient.

char2Digit contains the check which is where it belongs.

So, the question now seems, why are /you/ posting?

casting chars to ints, as though there wasn't implicit casting going on
by default. Then he tested for > '9', which made no sense to me. Realizing
that I wouldn't be able to trace that logic, I stopped.

It was a straightforward test for numerics. Again, are you qualified to
be in this discussion?

You stopped trying to understand things twice, so your opinion is
worth...what?


See above. I eventually realized that I would have to just rewrite the code to
have any hope of reading it. Your overly-long variable names, unnecessary casts,
useless functions, Hungarian notation, overly-spaced parentheses, and use of //
comments just didn't seem worth trying to understand.

So you gave up trying to understand, yet decided to post an attack
based on your failure to understand? Silence would have been a better
choice, but I guess you are another bully with a big mouth who gets a
hard on when he sees one person under attack.


What, if anything, can it be guaranteed will be > '9' in standard C?

This isn't grammatical therefore I do not fully understand it. If you
are saying there is no character greater than 9, well I wish you all
the best in your future career. You'll need it.


Don't quote signatures. You've been doing that all thread, and it's getting
annoying. My question was perfectly grammatical. Perhaps you should have
studied English more in high school.

No, it is not.

Nothing can be guaranteed >9. But this doesn't mean that the standard
forbids you to make the test, for greater than 9.

Perhaps I should have studied English more in high school at East
Bonehead, where "Coach" Trompska taught English. You don't understand
the difference between "might" and "must".


In fact, there /isn't/ any guarantee of a character greater than '9' in C.
I would think that since I understand the C standard far better than you,
perhaps /I/ should be wishing /you/ the best on your future career.

You may "understand" the C standard, perhaps in the manner of Dicken's
lawyer in Bleak House (who prided himself on reading nothing but case
materials on Jarndyce versus Jarndyce), but you don't know how to
program if you can, as you do above, compare apples and oranges, and
call a solution which doesn't check its input "simpler", therefore
better.

--
Andrew Poelstra < http://www.wpsoftware.net/blog >
To email me, use "apoelstra" at the above address.
I know that area of town like the back of my head.

.