Malcolm McLean said (in reply to me):
Corrrections are being stored up for an edition 2, which will be
released shortly.
I hope you will forgive us for continuing to breathe in the interim.
[no comment from MM]
You appear to have ignored this item.
There are two tables. One stores data items of any size, one stores
pointers.
Okay, fair point - let's try that one again, editing as appropriate:
I was puzzled to find that hash table entries were not abstracted as the
tables themselves were. "Divide and conquer" is too useful a strategy
to be ignored lightly, especially in teaching.
It's an algorithms book. The algorithms work on integers.
I think you'll find that hashing algorithms generally work on unsigned
integers.
The hash
function then has to to return a size_t, which is confusing to people
using the book to understand how to port to another language.
Fine, so use unsigned long int instead. Anyone can work out what that
means, and it's cross-portable between C90 and C99.
No, it isn't.
malloc( sizeof *ptr) is a bad clc ism
No, it's a good clc-ism.
that you will seldom see in another environment.
Right. As Sturgeon says, at least 90% of everything is crud, so you'd
expect to find malloc(sizeof *ptr) in only 10% of cases (or fewer).
That doesn't mean it's bad. It just means most people haven't come
across it yet.
The reader has to perform a mental dereference which makes it harder
to see if the size of correct.
If the reader has to perform a mental dereference, he (or she) doesn't
understand sizeof. No dereferencing occurs, because sizeof does not
evaluate its argument. Furthermore, the size is *bound* to be correct
for any object pointer type.
My convention is to have an opaque structure, and a constructor with
the name of the structure in lower case. This is analagous to C++. As
you say, create_xxx would have the advantage of being a verb.
Better: xxx_create or xxx_Create or something like that.
Read the actual book - preview is available.
I was reading the preview (presumably). Previews allow one to assess the
quality of the book prior to deciding whether to purchase it. I have no
intention of paying money for a book whose preview is of such low
quality.
The html is dumped form
the Open Office book files, unfortunately it doesn't understand code
formatting. I really ought to be able to find a way around that, I
know.
Yes, you ought to, really. I do sympathise about formatting issues -
deciding on a file format in the first place is no easy decision, since
at that stage it's quite probable that you don't know how you're going
to market the book, and you don't know whether other companies will be
involved - will they demand Word format? LaTeX? HTML? Impossible to
guess.
Nevertheless, if I can produce properly formatted code in HTML with
ease, I'm sure you can too, if you try. (And yes, I can.)
strdup() is discussed in chapter 1.
So the reference in the hash table chapter is to the strdup discussed in
chapter 1? Okay, fine - but *why*? After all, as I have already pointed
out above, the hash table code doesn't call strdup. It calls mystrdup.
These are different names.
Fixed yet?
I'll have to check on this one.
You're supposed to check on the basics of how basic algorithms work
*before* attempting to write a book about them. You have done your best
to deflect many criticisms about the quality of the code and the typos
and design decisions and so on, by saying that that's not what the book
is about - it's about explaining basic algorithms. Well, *this*
criticism drives a coach and horses through your strategy, because it
shows that you don't actually understand the algorithm you're trying to
teach.
You seem determined to pick faults.
If I were determined to pick faults, I would have gone over the chapter
with a fine-toothed comb. No, Malcolm - these faults jumped off the
screen and spat in my eye.
The problem it then becomes
distorting, like Ben Bacarisse's comments. It is then impossible to
know whether the criticisms actually represent anything legitimate or
are just fussing.
If a criticism that you don't understand the very algorithm you are
explaining is dismissed as "just fussing", then I see no hope for you.
A technical author must not just expect criticism, but be able to
analyse it, determine whether the criticism is proper (and as far as I
can tell, most and quite possibly all of the criticisms levelled at the
chapter are in fact proper and valid), and - wherever it *is* proper -
be prepared to take reasonable and prompt corrective action.
abstracted - is an entry of arbitrary size abstract enough? The keys,
yes, I admit it might have been better to go for non-strings.
I lack the perseverance to explain this to you. Let's see whether you
bother to correct any of the myriad more serious problems first.
size_t - yes, there is an obvious case, but you don't seem to have
considered the implications.
The obvious case is so powerful that the implications would have to be
drastic - and they aren't. You have tried hard to explain them to
several experts here, and convinced none of them. It may not have
occurred to you, but your inability to convince them might just be a
consequence of your arguments being wafer-thin.
malloc(size *ptr) - that's not the convention in most places. The
argument for it is based on the needs of the compiler rather than the
human reader.
On the contrary. The compiler doesn't give a damn how much you malloc.
The clc-conforming style is based on the needs of the programmer, for
whom it gives a simple and easy-to-use pattern.
verbs for function names. There is a case, but it is not obvious that
you are right. C++ doesn't agree.
C++ is irrelevant in comp.lang.c, and I await with interest your sound
logical reasons for giving a function a noun name.
indentations. Yes, it's my fault for not getting a decent HTML dumper.
If I edit the html
strdup - discussed in chapter 1.
menas - unambiguously valid criticism.
And the least important of many valid criticisms.
quadratic probing - you might be right here.
YOU SHOULD KNOW! Otherwise you have no business taking money off people
in return for teaching them how quadratic probing works! Okay, some
mistakes are inevitable - typos and stuff, even brainos - they happen.
But this is fundamental!
prime stuff - yes, that needs a bit of fixing, I will agree.
Indeed it does.
So actually most of the criticism dissolves.
No, it doesn't. You can't dissolve criticism by adding acid. You have
three choices:
1) pretend the criticisms are invalid - which fools nobody but yourself.
2) accept that they are valid, but do nothing to fix them.
3) accept that they are valid, and fix them.
4) show that they are not valid.
4) is best, but you haven't managed it here. 3) is next best, and
certainly good enough; 2) is not good, but at least it's honest; 1) is
a fake and a farce, and it seems to be the option you're choosing.
I am not saying that
there are not things you can say against the book, or that it couldn't
have been done better.
Just as well, since I've already said them, and it could. And should.
However can you point to a better introductory
web page on hash tables? That's the real test.
I think I'd struggle to find a worse one.