comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Case Insensitive Hash but still preserve cases of original keys
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Case Insensitive Hash but still preserve cases of original keys [message #84598] Tue, 15 July 2014 19:44 Go to previous message
SonicKenking is currently offline  SonicKenking
Messages: 51
Registered: October 2010
Member
On Tuesday, July 15, 2014 10:32:30 PM UTC+10, fawltyl...@gmail.com wrote:
> On Tuesday, July 15, 2014 1:11:06 PM UTC+2, SonicKenking wrote:
>
>
>
>> What I am confused is how PRINT gets the value for the key "X"? It seems to me that it should call something like self["X"], i.e. SpecialHash::_overloadBracketsRightSide. However it is not the case and this can be verified by setting a breakpoint as well.
>
>
>
> There is an undocumented function hash::get:
>
>
>
> IDL> print, (hash(0,0))[0]
>
> 0
>
> IDL> .comp hash_get
>
> % Compiled module: HASH::GET.
>
> IDL> print, (hash(0,0))[0]
>
> HASH::GET called: 0
>
> 0
>
> IDL>
>
>
>
> hash_get.pro is:
>
>
>
> function hash::get, key, _extra=ext
>
> print, 'HASH::GET called: ', key
>
> return, 0
>
> end
>
>
>
> PRINT probably calls self.get(...), so you can try to add a SpecialHash::Get function.
>
>
>
> regards,
>
> Lajos

Thanks Lajos. Override the Get() function solves the problem!

Inspired by your answer, I dug a bit more into the HASH internals. So HASH sometimes works off the internal data structure (e.g. TABLE_DATA) without consulting the public APIs. This creates problem for subclasses that alter the behaviors of public APIs.

One more example is that the FOREACH loop of SpecialHash display the key 'x' in lowercase, while it really should be in uppercase.

IDL> foreach v,h, k do print, k, v
x 1337

My guess is that Hash's foreach implementation gets the keys directly from the internal self.TABLE_DATA structure. The keys() function hence never gets called and doesn't have the chance to provide the correct case of key 'X'
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: shmmap error
Next Topic: Need to convert a grayscale image to a binary (1s and 0s) image...

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:31:17 PDT 2025

Total time taken to generate the page: 0.00433 seconds