realbasic-nug
[Top] [All Lists]

Re: Doh! Variant.Hash is case insenstive Re: Variant.Hash for object

To: REALbasic Network Users Group <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Doh! Variant.Hash is case insenstive Re: Variant.Hash for objects is not unique in RB 2005 v4
From: Roph <Roph at kc dot rr dot com>
Date: Wed, 30 Nov 2005 09:54:26 -0600
Delivered-to: realbasic-nug at lists dot realsoftware dot com
Thread-index: AcX1xlbjlSeR2GG5Edq1/wANk0o3Jg==
Thread-topic: Doh! Variant.Hash is case insenstive Re: Variant.Hash for objects is not unique in RB 2005 v4


On 11/30/05 9:16 AM, "Joseph J. Strout" <joe at realsoftware dot com> wrote:

> At 6:09 PM -0600 11/29/05, Roph wrote:
> 
>> I just discovered that the Variant.Hash method is case-insenstive for
>> strings.
> 
> That's true (and intentional).
> 

LOL, yes so I readily concluded from Mars' short retort.
On the one hand, it makes sense -- it's consistent with the RB common usage
of strings being case insensitive.   On the other hand every time I get a
reply such as Mars' last one telling me something like this I find it really
frustrating.  The implication I read into it, whether intended or not, is
"Well if RB doesn't need it or inherently work that way, we certainly have
no intention of providing it for other possible uses".   I'm sure that's not
what was intended on his part in that email, nor on your part below, but
it's the way I frequently feel when reading such replies.

>> 1) Fix this by making the hash function case sensitive for strings so it is
>> usable in case-sensitive algorithms.
> 
> They already are.  String hashes are necessarily non-unique, so
> you'll always have to check for collisions anyway.

Yes, of course.  But there's a difference in having a case-senstive hash so
that it is highly unlikely that you have to ever incur the processing
overhead for dealing with a collision, and having a case-insensitive hash
that guarantees you'll have to invoke your hash collision logic frequently
and repeatedly because all uses of "text", "TEXT", and "Text" will
necessarily hash to the same value.

> However, the 
> standard behavior for a hash function is that if x = y, then Hash(x)
> = Hash(y).  Since '=' for strings is case insensitive, then it's
> correct (and important) that Hash for strings be the same.  If you
> want to handle collisions by using StrComp instead of '=', you can
> still do that.

But I can't have a hash function that supports it efficiently unless I write
it myself.
Yes,  Understood.  Not appreciated, but understood.
 
> Best,
> - Joe

Thanks. 


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>