On 11/6/2010 02:47, Walter Bright wrote: > Rainer Deyke wrote: >> On 11/5/2010 17:41, Walter Bright wrote: >>> In other words, I create an array that I mean to fill in later, because >>> I don't have meaningful data for it in advance. >> >> That's a faulty idiom. A data structure that exists but contains no >> valid data is a bug waiting to happen - no, it /is/ a bug, even if it >> does not yet manifest as incorrect observable behavior. (Or at best, >> it's an unsafe optimization technique that should be wrapped up in an >> encapsulating function.) > > An example would be the bucket array for a hash table. It starts out > initially empty, and values get added to it. I have a hard time agreeing > that such a ubiquitous and useful data structure is a bad idiom.
Empty is a valid value for a hash table, so that's a completely different situation. Obviously the bucket array would not use a non-nullable type, and less obviously the bucket array should be explicitly initialized to nulls at creation time. -- Rainer Deyke - [email protected]
