On Tue, Jan 20, 2009 at 11:15:02PM +0000, Martin Stjernholm, Roxen IS @ Pike
developers forum wrote:
> array a = ({0});
> for (int i = 1; i < 1000; i++)
> a += ({i});
> (To make the example simpler, I start out with the array ({0}) instead
> of the empty array ({}) since the empty array always is shared.)
is that actually making code faster or is it only to make the logic of
the problem you are discussing simpler?
> One alternative is to extend the array type to explicitly allow adding
> elements to the end destructively. It could perhaps look like this:
> a[sizeof (a)] = i;
what about possible code that expects this operation to fail?
mixed error = catch{ a[x] = i; };
if (error)
write("ooops, we reached the end\n");
greetings, martin.