Any reason as to why this isn't allowed?

Lass Safin via Digitalmars-d digitalmars-d at puremagic.com
Sat Apr 2 10:44:24 PDT 2016


On Saturday, 2 April 2016 at 16:58:14 UTC, Paul O'Neil wrote:
> On 04/02/2016 09:02 AM, Lass Safin wrote:
>> class C {
>>          ~this() {}
>>          immutable ~this() {}
>> }
>>
>> This gives a conflict error between the two destructors.
>
> What do you expect the difference to be?  I'm not sure what I 
> expect the semantics of destroying an immutable object to be.

It's more that I wish the immutable destructor to be empty, thus 
never destroying it properly.

I just don't really see the reason as to why we can have 
immutable and mutable constructors but not immutable and mutable 
destructors.

Though currently it is possible if I create two functions, one 
immutable and one not, then set the value inside the vtable 
manually within two constructors, again, one immutable and one 
not.


More information about the Digitalmars-d mailing list