Alternative destructors, do/should we have them?

Dukc ajieskola at gmail.com
Thu Jul 5 18:09:25 UTC 2018


On Thursday, 5 July 2018 at 15:58:14 UTC, Andrea Fontana wrote:
> On Thursday, 5 July 2018 at 10:57:51 UTC, Dukc wrote:
>> If not, should we in your opinion have an ability to define an 
>> alternative destructor which runs only when explicitly 
>> requested?
>
> What does "when explicity requested" mean?

That the alternative destructor runs only when you ask it to. 
There would be some way to say before an end of a block, return 
statement, break statement ect that you want the alternative 
destructor to be applied to the struct.

The normal destructor would not run when an alternative one is 
used, but would run otherwise.

In fact, in this case it would be enough to elide the destructor 
somehow.


More information about the Digitalmars-d mailing list