From: Rick M. <obj...@gm...> - 2007-04-20 09:08:56
|
You might want to refer back to the recent conversation in the archives about the problems with MAKESTRING on the array class. This is another unintended consequence of having array automatically convert itself to a string via the MAKESTRING method. Here's essentially what happens. The table class searches for index maps using a combination of the object's hash value and doing an "==" comparison on the indexes stored in the same hash bucket. Since your search index is a string, the "==" method for the string class does a REQUEST("STRING") on the other object. If the request returns .nil, then the compare result is false. If REQUEST does return a string, then the string class is happy, and compares its value with the other using a string comparison. Unfortunately, since array has a MAKESTRING method, it is happily converting itself into a string for the compare, resulting in this false positive. It appears somewhat random because it only occurs when the object hash ends up placing them in the same hash table bucket. The 3.2 release has disabled the automatic conversion of arrays and makestring is going to be deprecated in favor of a "toString" method that's not tied into the automatic coercions. I'm going to answer your bug report as "already fixed". I'm really quite impressed you managed to narrow down the bad behavior this way! Rick On 4/20/07, Moritz Hoffmann <mo...@gm...> wrote: > > Hello, > the Table class seems to have a bug. When an array with one element is > added (for example .array~of("xxx")) to a table a table~hasindex("xxx") will > report .true every 5 to 10 calls. The strings have to be equal. > > Tested on ooRexx 3.1.2 on Debian lenny/sid (testing), both the sarge dab > package and a custome compile with current svn source. > > See testcase. > > #!/opt/ooRexx/bin/rexx > stop = .false; i = 0 > do until stop > i = i + 1 > array = .array~of("xxx") > t = .table~new > t[array ] = 1 > -- should .false all the time! > stop = t~hasindex("xxx") > end > Say "Exit after" i "cycles" > > > Regards, Moritz > -- > "Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ... > Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Oorexx-devel mailing list > Oor...@li... > https://lists.sourceforge.net/lists/listinfo/oorexx-devel > |