Safe mode in D?
Maxim Fomin
maxim at maxim-fomin.ru
Fri Oct 18 12:28:33 PDT 2013
On Friday, 18 October 2013 at 18:59:46 UTC, Andrei Alexandrescu
wrote:
>
> I think one good compromise is to stick with the exact amount
> of flow control we currently have in constructors (which is
> primitive but quite adequate), and use that creatively. It's
> already implemented and works, so the implementation costs of
> applying it to other cases should be low.
>
> Andrei
Do you mean preventing calling constructor (from another
constructor) within one control branch? May be this will be case
#13.
import std.stdio;
extern(C) void _D4main1A6__ctorMFiZC4main1A(A a, int i);
class A
{
this(int i) { writeln("reached"); }
this()
{
int i = 1;
//if (i)
// this(i); // Error: one path skips constructor
if (i)
_D4main1A6__ctorMFiZC4main1A(this, i);
if (i)
auto dg = __traits(getOverloads, this, "__ctor")[0](i);
}
}
void main()
{
new A;
}
More information about the Digitalmars-d
mailing list