More radical ideas about gc and reference counting

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Fri May 2 14:10:38 PDT 2014


On Fri, May 02, 2014 at 09:03:15PM +0000, monarch_dodra via Digitalmars-d wrote:
> On Friday, 2 May 2014 at 15:06:59 UTC, Andrei Alexandrescu wrote:
> >So now it looks like dynamic arrays also can't contain structs with
> >destructors :o). -- Andrei
> 
> Well, that's always been the case, and even worst, since in a dynamic
> array, destructor are guaranteed to *never* be run. Furthermore, given
> the "append causes relocation which duplicates", you are almost
> *guaranteed* to leak your destructors. You just can't keep track of
> the usage of a "naked" dynamic array.
> 
> This usually comes as a great surprise to users in ".learn". It's also
> the reason why using "File[]" never ends well...

This is why I'm unhappy with the way this is going. Current behaviour of
structs with dtors is already fragile enough, now we're pulling the rug
out from under classes as well. So that will be yet another case where
dtors won't work as expected.

I'm getting the feeling that dtors were bolted on as an afterthought,
and only works properly for a very narrow spectrum of use cases. Rather
than expand the usable cases, we're proposing to reduce them (by getting
rid of class dtors). I can't see *this* ending well either. :-(


T

-- 
Democracy: The triumph of popularity over principle. -- C.Bond


More information about the Digitalmars-d mailing list