D's Destructors are What Scott Meyers Warned Us About

Steven Schveighoffer schveiguy at yahoo.com
Wed May 23 17:59:04 UTC 2018


On 5/23/18 1:41 PM, Manu wrote:
> On 23 May 2018 at 05:38, Steven Schveighoffer via Digitalmars-d
> <digitalmars-d at puremagic.com> wrote:
>> On 5/22/18 10:15 PM, Manu wrote:
>>>
>>> If you're in the mood to prepare a DIP, I think you should prepare this
>>> dip:
>>>
>>> Support the syntax:
>>>     classInstance.~this();
>>
>>
>> Isn't this just classInstance.destroy() ?
> 
> Is everything in object.d globally available? You don't have to import
> `destroy()` right?
> My nit-pick is that destroy resets to .init after destruction, which
> makes it feel like more than a destroy, and that is almost certainly
> the reason people reach for __xdtor() when they do (ie, they JUST want
> to destruct).
> We should probably address that, and then publish a strong recommendation.
> 

I think it's a good idea. Like unsafeDestroy.

-Steve


More information about the Digitalmars-d mailing list