Safe mode in D?
Maxim Fomin
maxim at maxim-fomin.ru
Fri Oct 18 13:03:21 PDT 2013
On Friday, 18 October 2013 at 19:46:44 UTC, Max Samukha wrote:
> On Friday, 18 October 2013 at 19:28:35 UTC, Maxim Fomin wrote:
>> 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;
>> }
>
> Wanna talk about what can be done with reflection in "safe" C#?
You are free to present horrible bugs of "unsafe" C#, but I bet
they are far, very far to DMD bugs/D design issues of "safe" D.
(By the way, I don't see why the code above provoked you to C#
talks).
More information about the Digitalmars-d
mailing list