"Kelsey Bjarnason" <> wrote in message
news:5huun4-...
> [snips]
>
> On Thu, 19 Jul 2007 21:20:02 +0100, Malcolm McLean wrote:
>
>> Buy my book, Basic Algorithms.
>
> Or not. Let's see:
>
> int strlen(const char *str)
>
> You follow up your example with one that uses size_t and even explains why
> you should use size_t... which raises the obvious question why include
> such a badly broken example at all?
>
>
> This is followed up by, among other things, strcount which counts the
> number of characters in a string. Problem: it returns an int, which
> you've already said, on that very page, is a bad idea, yet here you go
> doing it again, apparently oblivious to the notion that the string could
> just as easily be longer than the range of an int *and* be filled with a
> single character.
>
> int squnch(void *data, int len, void *out)
>
> Er... no. Once again, a complete failure to grasp the concept of size_t
> and its reason for existence. One might also ask the utility of
> (len & 0xFF000000) >> 24; where len is an int and the code is being
> compiled on a 16-bit implementation. One might *also* ask the reasoning
> behind using *signed* ints for sizes; do you expect a lot of negative
> length buffers to compress?
>
> In fact, the entire example set seems to suggest a serious fetish for
> using inappropriate types and inappropriate assumptions on sizes and the
> like. How the hell did you get this past a reviewer or editor?
>
I do most of my programming on parallel hardware.
There is no interface for passing size_ts over the system. You can do so, of
course, by hardcoding in the bit size, or converting to integers, or simply
passing as a bit buffer. But that sort of thing adds complexity I don't
need.
There are good reasons for disliking size_t. That's just one of them. It
certainly isn't a case of not being able to grasp the concept. I explain,
rightly or wrongly, in the first paragraphs the coding conventions I am
using, and the justification for them.
The programs contain operations on integers, characters, and reals. I don't
want a zoo of types.
--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm