RFC: Change what assert does on error
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Sat Jul 5 08:47:44 UTC 2025
On 05/07/2025 6:57 PM, Jonathan M Davis wrote:
> On Friday, July 4, 2025 5:09:27 PM Mountain Daylight Time Timon Gehr via
> Digitalmars-d wrote:
>
>
> A destructor can do anything, not just call |free|. Not calling them
> is way more likely to leave behind an unexpected state than even the
> original error condition. The state can be perfectly fine, it's just
> that the code that attempted to operate on it may be buggy.
>
>
> This is particularly true if RAII is used. For instance, the way that
> MFC implemented turning the cursor into an hourglass was with RAII, so
> that you just declared the thing, so when the variable was created, the
> cursor turned into an hourglass, and when the scope exited, the variable
> was destroyed, and the cursor went back to normal.
>
>
> RAII is used less in D than in C++ (if nothing else, because we have
> scope statements), but it's a design pattern that D supports, and
> programmers can use it for all kinds of stuff that has absolutely
> nothing to do with memory allocations.
Don't forget there is also COM, which if not cleaned up properly will
affect other processes including the Windows shell itself.
More information about the Digitalmars-d
mailing list