www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Any reason as to why this isn't allowed?

reply Lass Safin <lasssafin gmail.com> writes:
class C {
         ~this() {}
         immutable ~this() {}
}

This gives a conflict error between the two destructors.
Apr 02 2016
next sibling parent reply Paul O'Neil <redballoon36 gmail.com> writes:
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.
Apr 02 2016
parent Lass Safin <lasssafin gmail.com> writes:
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.
Apr 02 2016
prev sibling parent Marco Leise <Marco.Leise gmx.de> writes:
Am Sat, 02 Apr 2016 13:02:18 +0000
schrieb Lass Safin <lasssafin gmail.com>:

 class C {
          ~this() {}
          immutable ~this() {}
 }
 
 This gives a conflict error between the two destructors.
That is https://issues.dlang.org/show_bug.cgi?id=13628 -- Marco
Apr 04 2016