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

https://forum.dlang.org/thread/qwixdanceeupdefyq...@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;
}
  • Release D 2.1... Iain Buclaw via Digitalmars-d-announce
    • Re: Rele... M.M. via Digitalmars-d-announce
    • Re: Rele... Richard (Rikki) Andrew Cattermole via Digitalmars-d-announce
    • Re: Rele... jmh530 via Digitalmars-d-announce
      • Re: ... Steven Schveighoffer via Digitalmars-d-announce
        • ... jmh530 via Digitalmars-d-announce
    • Re: Rele... Ali Çehreli via Digitalmars-d-announce
      • Re: ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-announce
      • Re: ... jmh530 via Digitalmars-d-announce
        • ... Ali Çehreli via Digitalmars-d-announce
          • ... Max Samukha via Digitalmars-d-announce
            • ... Mathias LANG via Digitalmars-d-announce
      • Re: ... Iain Buclaw via Digitalmars-d-announce
      • Re: ... Salih Dincer via Digitalmars-d-announce
    • Re: Rele... Andrej Mitrovic via Digitalmars-d-announce
    • Re: Rele... ryuukk_ via Digitalmars-d-announce
    • Re: Rele... Andrej Mitrovic via Digitalmars-d-announce
      • Re: ... Iain Buclaw via Digitalmars-d-announce
        • ... notna via Digitalmars-d-announce
    • Re: Rele... Iain Buclaw via Digitalmars-d-announce
      • Re: ... Iain Buclaw via Digitalmars-d-announce

Reply via email to