D 2015/2016 Vision?

ponce via Digitalmars-d digitalmars-d at puremagic.com
Tue Oct 6 13:44:21 PDT 2015


On Tuesday, 6 October 2015 at 17:20:39 UTC, Jonathan M Davis 
wrote:
>
> But in general, at this point, with D, if you want 
> deterministic destruction, then you use structs. Classes are 
> not the appropriate place for it. If they were ref-counted, 
> then they could be, but as long as they're not, then classes 
> are not the place to have stuff that cares about deterministic 
> destruction. And if you're stuck with stuff in classes that do 
> care about deterministic destruction, then you have to use the 
> sort of solutions that C# and Java use where you don't rely on 
> the destructor/finalizer to clean anything up except for the 
> cases where you screw up and forget to manually call the 
> function that does the cleanup.

Unfortunately, it is quite common to need both virtual functions 
and deterministic destruction. It isn't helpful to disregard the 
problem by saying "you should have used a struct", in many cases 
it's not any easier.




More information about the Digitalmars-d mailing list