William James wrote:
> James Coglan wrote:
> 
>> [Note:  parts of this message were removed to make it a legal
>> post.]
>>
>>>> Regardless of whether they're supposed to, the Rubies
>>>> I've used before 1.8.7 actually do iterate in insertion
>>>> order.
>>> NO THEY DO NOT. It is the nature of a regular hashtable that
>>> the order of entries in its internal data structures depends
>>> only on the hash function and its inputs. It doesn't know
>>> anything about the order of entries in your hash literal.
>>>
>>> I've shown you examples using Ruby *1.8.6* that clearly
>>> demonstrate that it gives a **** about order of appearance
>>> in a literal, or insertion order.
>>
>>
>> I'm really not up for a slanging match so let me just say
>> that, in code I've written, Ruby < 1.8.7 has demonstrated the
>> behaviour I described. This may be a fluke or a bug, in which
>> case I will investigate further and file bugs if necessary.
>> What I do know is that I've had code in a library released
>> over 2 years ago and used by a fair number of people relying
>> on this behaviour and heard no complaints until 1.8.7
>> arrived.
> 
> It's bad to write code that works by accident.
> It's good to write code that works by design.
> 
>>            I realise that hashtables are not ordered in 1.8
> 
> Normal hash-tables are ordered nowhere, no-how, and no-way.
> 
>>  and
>> have since made my code more robust.  I'm not questioning
>> your examples -- you can but experiment to see what works --
>> and I will try to extract the code from my project that
>> demonstrates my point when I have some time.
>>
>> I'm not the least bit interested in who's right or wrong or
>> in berating the Ruby code devs or indeed anyone else, and was
>> hoping for a productive discussion, not people repeatedly
>> asserting that I don't know how a hash table works
> 
> Do you understand how a hash-table works?  Have you ever
> implemented one?  Have you studied hash-table code written
> by someone else?
> 
> A 9-year-old boy wanted to keep track of the color of his
> toys.  He wrote "car: red" on a piece of paper which he then
> put in a bag.  Then he did the same with "airplane: silver"
> and "ball: blue".  Days later, he decided to review the data.
> He reached into the bag and pulled out a slip.  It didn't
> say "car"!  It was the slip with the color of the ball!
> The slips were coming out in the wrong order!
> Devestated, he began crying and ran to his mommy.

Um, how is bag["car"] implemented? How is this analogous with a hash? Do 
*you* understand how a hash-table works? (Yes, I know you do.)

-- 
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407