Don't use arrays as stacks

Nick Sabalausky a at a.a
Sun Sep 25 04:05:34 PDT 2011


"Jonathan M Davis" <jmdavisProg at gmx.com> wrote in message 
news:mailman.160.1316939358.26225.digitalmars-d at puremagic.com...
> On Sunday, September 25, 2011 03:18:29 Andrew Wiley wrote:
>>
>> Isn't this exactly what assumeSafeAppend is for?

Hmm, I didn't know about that. (Actually, I remember hearing it mentioned 
before, but then totally forgot about it.)

>
> and if you're using assumeSafeAppend, then you
> need to guarantee that nowhere else has a reference to that array 
> (otherwise
> it's _not_ safe to assume that it's safe to append)
>

Would the consequences of failing to do that be any worse (or any different 
at all?) than what I mentioned about:

"One caveat about this method: If you save a slice of the stack, pop 
elements off the stack, and then push new values back on, the old slice you 
took will likely reflect the new values, not the original ones."

...? 




More information about the Digitalmars-d mailing list