On 12/12/16 23:02, Andrei Alexandrescu wrote:
On 12/12/2016 02:54 PM, Shachar Shemesh wrote:
On 12/12/16 17:51, Andrei Alexandrescu wrote:
Here it is:

https://github.com/dlang/druntime/pull/1710

It relieves code that uses assert from needing the GC. I think all
Errors should be singletons - multiple objects in that hierarchy
arguably make no sense. But of course there are many situations out
there. If this breaks your code, please holler.


Andrei

As you may know, Weka has a huge GC aversion. Despite that fact, I fail
to see the improvement such a change would bring.

Why am I not surprised :o).

I'm not sure what to make of that comment.


The only situation
under which using the GC is not harmful is when the entire process is
about to go kaboom anyways.

You get to use assert without needing to link in the GC.


int func(int num1, int num2, int num3)
body
{
    int result;
    scope(exit)
            assert(result>20);

    assert(num1>5);
    result += num1;
    assert(num2>10);
    result += num2;
    assert(num3>5);
    result += num3;

    // Some more work

    return result;
}

Yes, I know, there multiple ways in which this function can be written much better, and in all of them the double assert won't happen. Such a case may actually happen, however, particularly if the first assert to happen happens in a sub-function.

What is supposed to happen, after your proposed change, if I call "func(1, 2, 3)"?

Shachar

Reply via email to