On Friday, January 05, 2018 15:26:03 12345swordy via Digitalmars-d wrote: > On Friday, 5 January 2018 at 14:35:44 UTC, Jonathan M Davis wrote: > > On Friday, January 05, 2018 14:29:41 Adam D. Ruppe via > > > > Digitalmars-d wrote: > >> [...] > > > > Either that or use structs on the stack instead of classes on > > the heap so that you're actually using destructors instead of > > finalizers. > > > > - Jonathan M Davis > > There been discussions regarding spiting up the destruction and > finalizers.
Part of the problem with that is that if you stick a struct on the heap, its destructor becomes a finalizer. And for that matter, a class' finalizer becomes a destructor if you put in on the stack with scope or std.typecons.scoped. So, while you generally code as if structs have destructors and classes have finalizers, that distinction isn't entirely true. And if destructors and finalizers are different, then suddenly you have to implement two different functions to do more or less the same thing. That wouldn't be all bad, because on some level, it would force folks to consider the consequences of putting stuff on the heap vs the stack with regards to destruction, but in practice, it probably would result in folks either just usually implementing one and cause problems because of that or blindly making one call the other or make both call a common function to shared code. It could very well be that changing how destructors and finalizers are declared should be done, but it's not exactly a straightforward issue, and we'd need to come up with something that was clearly better for it to make sense to make a change. - Jonathan M Davis
