Possible change to array runtime?

Steven Schveighoffer schveiguy at yahoo.com
Thu Mar 13 09:17:17 PDT 2014


On Thu, 13 Mar 2014 11:53:15 -0400, monarch_dodra <monarchdodra at gmail.com>  
wrote:

> On Thursday, 13 March 2014 at 15:24:01 UTC, Steven Schveighoffer wrote:
>>
>> Destroy.
>>
>> -Steve
>
> Please keep in mind that if the objects stored are RAII, then if/when we  
> will have a finalizing GC, the stomped elements will have been leaked.
>
> Clobbering elements is more than just "I won't use these elements  
> anymore", it's "I won't use them, and they are safe to be discarded of  
> right now".
>
> In know that's a big "if", but it could happen. If we go the way of your  
> proposal, we are definitively closing that door.

I'm not understanding this. Can you explain further/give example?

> Semi-on topic, it would greatly help if assumeSafeAppend was nothrow. As  
> of right now, there are a lot of places in phobos where it could be  
> used, but isn't, because of this. In particular, assumeSafeAppend can be  
> used to both shrink an array, *or* grow an array up-to capacity.
>
> Its greater use in phobos would help give it more visibility and  
> exposure.

https://github.com/D-Programming-Language/druntime/pull/147

reserve and capacity were made nothrow, not sure why assumeSafeAppend  
shouldn't also be.

-Steve


More information about the Digitalmars-d mailing list