D array expansion and non-deterministic re-allocation

Simen kjaeraas simen.kjaras at gmail.com
Wed Nov 25 05:44:11 PST 2009


Steven Schveighoffer <schveiguy at yahoo.com> wrote:

>> You are again resorting to implementation. I guess in the current  
>> implementation it's true that the compiler will indeed insert a call to  
>> its internal function. But the language spec does not proscribe that.
>>
>
> Sure it does.  It says that setting the length may reallocate the array  
> to hold enough space.  How do you do that without a function call?

As long as the compiler is aware of arrays' existence, and knows how
those functions work, there might indeed be an optimization that turns
length+=1;length-=1; into a nop. There isn't at the moment, and there
might never be, but it's a conceivable optimization.

-- 
Simen



More information about the Digitalmars-d mailing list