Release D 2.102.0

Max Samukha maxsamukha at gmail.com
Fri Feb 3 08:33:26 UTC 2023


On Thursday, 2 February 2023 at 22:46:51 UTC, Ali Çehreli wrote:

> https://forum.dlang.org/thread/qwixdanceeupdefyqwnr@forum.dlang.org
>
> I still agree with myself :) in that discussion here:
>
>   https://forum.dlang.org/post/tlqcjq$usk$1@digitalmars.com
>

BTW, check out another case of D violating the "if in an invalid 
state, die" precept. The following code not only runs the 
upstream destructor (which depends on successful completion of 
the downstream one), but does that in an infinite loop:

struct TransactionFactory
{
     Transaction spawnTransaction()
     {
         return Transaction(0);
     }

     // depends on all Transactions having been destroyed
     ~this()
     {
         assert(Transaction.count == 0);
     }
}

struct Transaction
{
     static int count;

     // the usual "fake nullary constructor" fiddlesticks
     this() @disable;
     this(int dummy)
     {
         count++;
     }

     ~this()
     {
         assert(false); // a failure that leaves the system in an 
invalid state
         count--;
     }
}

void main()
{
     TransactionFactory tf;
     Transaction t = tf.spawnTransaction;
}


More information about the Digitalmars-d-announce mailing list