Walter Bright, el 6 de noviembre a las 01:47 me escribiste: > 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.
In that example, null is *valid* data. Invalid data is when it has no meaning to your algorithm and in you example null has a very important meaning. -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------- Un camión lleno de amigos, míos. Cada uno dando vueltas, en su cabeza. Mientras yo, sufro la picadura de mi propia abeja.
