On Fri, May 02, 2014 at 11:44:47PM +0200, Jonathan M Davis via Digitalmars-d wrote: > On Fri, 02 May 2014 21:03:15 +0000 > monarch_dodra via Digitalmars-d <digitalmars-d@puremagic.com> 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... > > Heck, I probably knew that before, but I had completely forgotten. If > you'd asked me yesterday whether struct destructors were run in > dynamic arrays, I'd have said yes. And if someone like me doesn't > remember that, would you expect the average D programmer to? The > current situation is just plain bug-prone. > > Honestly, I really think that we need to figure out how to make it so > that struct destructors are guaranteed to be run so long as the memory > that they're in is collected. Without that, having destructors in > structs anywhere other than directly on the stack is pretty much > broken. [...]
Thank you, that's what I've been trying to say. Having dtors sometimes run and sometimes not, is very bug-prone -- if for a seasoned D programmer, then how much more for an average D programmer? We need some kind of guarantees. The current situation sux. I might even say we'd have been better off having no dtors in the first place -- at least then it's consistent, you know you always have to cleanup. But the current situation of being neither here nor there, neither always cleaning up nor never, is not a good place to be in. I've to say that the more I look at this, the more I don't like this part of the language. :-/ T -- MASM = Mana Ada Sistem, Man!