knowledge-database (beta)

Current group: comp.lang.objective-c

What to believe in ?

What to believe in ?  
bazad
 Re: What to believe in ?  
Tilo_Prütz
From:bazad
Subject:What to believe in ?
Date:20 Nov 2004 03:49:24 -0800
GNU objc/hash.h contains the following text:

/*
* This data type is the function that compares two hash keys and returns an
* integer greater than, equal to, or less than 0, according as the first
* parameter is lexicographically greater than, equal to, or less than the
* second.
*/

typedef int (*compare_func_type)(const void *, const void *);

Later on you can find an implementation of this function type.

/* Compare two strings. */
static inline int
compare_strings (const void *k1, const void *k2)
{
if (k1 == k2)
return 1;
else if (k1 == 0 || k2 == 0)
return 0;
else
return !strcmp (k1, k2);
}

Now, I an not an expert in C and Objective-C, but I can say that the
original description is not followed at all!

The actual signauture is something like:
return 1 if data is equal
return 0 if data is not equal

Pointers follow the same rule. It is even more descriptive:

/* Compare two pointers for equality. */
static inline int
compare_ptrs (const void *k1, const void *k2)
{
return !(k1 - k2);
}

I expected better from the core level of the GNU code.

Needless to say I wasted lots and lots of time...
From:Tilo_Prütz
Subject:Re: What to believe in ?
Date:Sat, 20 Nov 2004 13:09:17 +0100
bazad wrote:

>
> I expected better from the core level of the GNU code.
>
> Needless to say I wasted lots and lots of time...

Me, too. You can't rely on the libobjc. Either use a complete framework
like GNUstep or libFoundation or program your own (as I do for fun and for
learning :)).

And if you ever come to the point where you need to know which methods are
supported by a protocol:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18255


greetz

>tilo
   

Copyright © 2006 knowledge-database   -   All rights reserved