C++17

Chris Wright via Digitalmars-d digitalmars-d at puremagic.com
Wed Jan 27 13:03:15 PST 2016


On Wed, 27 Jan 2016 20:28:42 +0000, deadalnix wrote:

> On Wednesday, 27 January 2016 at 14:22:18 UTC, Shachar Shemesh wrote:
>> I bring it up every time the subject comes up, in the hopes that at
>> some point it will sink in.
>>
>> No, D is not capable of doing it already. Without 100% reliable
>> destructors, RAII is simply not implementable.
>>
>> D's destructors are not guaranteed to run on 100% of fully initialized
>> structs, which means that a RAII container has no way to make sure its
>> resource is actually freed. It is up to the implementer. This
>> eradicates almost all of the utility RAII was meant to provide.
>>
>> Shachar
> 
> The only time it may not run, it is when these are collected by the GC.
> Which is not a problem if you want to use RAII, as in C++, to not use a
> GC.

Shachar Shemesh showed us that a struct's fields do not have their 
destructors called when the struct's constructor throws an exception.

This doesn't make RAII impossible. It's an unexpected annoyance, though, 
and it complicates the use of RAII. On the plus side, there's a pull 
request to change this.


More information about the Digitalmars-d mailing list