On Wed, 05 Nov 2008, Mindaugas Kavaliauskas wrote:

Hi Mindaugas,

> I see Przemek has already implemented national/binary hash ordering, so my 
> remarks are too late, but I really do not understand a problem here.
> From my point of view hash is a way to obtain data value by key value (not 
> by number like in array).

To be precise: hashes allows to operate non continuous on indexes.
These indexes does not have to be strings.
F.e. AFAIR you are using pointers.

> The internal implementation of the hash it is hash's business.
> Have we documented, that hash uses sorted array and binary search to find a 
> key value? Have we documented that HB_HGETKEYS() should return string keys 
> in ascending order? If we did it, then it's a documentation bug!!! I think 
> hash is hash, and user code should not depend on hash internal 
> implementation.
> We can use any algorithm for sorting keys. We can also use the real hashing 
> algorithm, i.e. generate some checksum of key, and try to find value using 
> this checksum. In this case national/binary sorting is not used at all.
> So, I do not understand at all, why do we need hb_hSetBinary() and 
> hb_hBinary()?!It should be hash's internals and users should not care about 
> it!

I fully agree. But I didn't want to discuss about it. I still remember from
my xHarbour days discussion about keeping build order in hashes for
replicating associated arrays class behavior.
If we can agree that we do not need backward internal order compatibility
then I'll be very happy in removing hb_hBinary().
But please do not forget about one thing. National sorting can cause
that two different keys will be equal in some languages. It's the same
problem like with CASEMATCH flag. So hb_hBinary() does not only change
the internal item order but also keys hashing method.

BTW in PHP hash value items are kept in build order and can be resorted by
    user manually and PHP authors documented it.

best regards,
Przemek
_______________________________________________
Harbour mailing list
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to