On 5/16/2011 12:38 PM, Andrei Alexandrescu wrote:
Oh, I see.
Wait, what bug are you referring to, though?

I was mistaken and removed my post. The code ingeniously redefines the
problem - instead of removing from the array by shifting its tail
downwards, it shifts elements upwards from the head of the array. A nice
hack, but I don't think it does a lot in helping your situation.

There's a bit of history wrt ~=. Initially the behavior was to never
reallocate if there was enough capacity. But that caused a stomping
issue - people would create an array, pass a slice of it to a function,
and then the function would clobber elements in the arrays outside the
slice. This was a major breakage of modular behavior so we decided to
change the behavior: as long as you keep references to the original
array, appending to a slice of it will cause reallocation of the array.

One thing you could do is to think of what you're trying to achieve on a
larger scale. Assuming a slice to grow over the original array is
arguably a bad behavior that I'm sure could be fixed by small changes in
the design.


Andrei

It seems to be fine for what I need, although I'm going to put a comment in my code because I'm sure I'm going to run into a problem with it down the road... for now it seems safe though. :)

Thanks!

Reply via email to