On Wednesday, 21 November 2018 at 14:21:44 UTC, Kagamin wrote:

A value passed to ref parameter is assumed to be initialized. C# would reject to call function foo.

This was not my point. I wonder, whether the case, where the compiler can't figure out the initialization state of an object is so hard to construct.

´´´
import std.experimental.all;

class C
{
        size_t dummy;
        final void baz()
        {
                if(this is null)
                {
                        writeln(42);
                }
                else
                {
                        writeln(dummy);
                }
        }
}
void main()
{
        C c;
        if(uniform01 < 0.5)
        {
                c = new C();
                c.dummy = unpredictableSeed;
        }
        else
        {
                c = null;
        }
        c.baz;
        writeln(c is null);
}
´´´

C# wouldn't reject the case above, would it?

Reply via email to