April 10, 2014
On Thursday, 10 April 2014 at 13:57:26 UTC, Chris wrote:
> The funny thing, though, is that after clearing buf
>
> writeln(data1[0]);
>
> still prints "World1". It only changes after I add a new item to buf.

clear doesn't actually "clear" in the "wipe" sense of the word.
It only means that the data is considered "not interesting", and
free for overwrite.
April 10, 2014
On Thursday, 10 April 2014 at 13:47:22 UTC, monarch_dodra wrote:

> That said, it feels like you are using Appender like a container. Maybe "Array" is a better fit?

It is not really a container in the sense that I add and remove items at random later in the program. The items are added in a loop after initialization (say every single letter of a word). Since it happens very often and there can be loads of items each time, I use appender to fill it up fast and efficiently. What goes in there should not be controlled by the struct itself. It's half container, half buffer / appender.
April 10, 2014
On Thursday, 10 April 2014 at 14:16:02 UTC, Rene Zwanenburg wrote:
> On Thursday, 10 April 2014 at 13:57:26 UTC, Chris wrote:
>>
>> The funny thing, though, is that after clearing buf
>>
>> writeln(data1[0]);
>>
>> still prints "World1". It only changes after I add a new item to buf.
>
> Correct. The memory has not been touched by clear(), it just sets it's internal used elements counter to 0. When adding new items the old ones will be overwritten.

A source of subtle bugs. Good that I asked.
1 2
Next ›   Last »