Reddit: why aren't people using D?

Sergey Gromov snake.scaly at gmail.com
Mon Jul 27 05:12:16 PDT 2009


Sun, 26 Jul 2009 21:23:35 -0500, Andrei Alexandrescu wrote:

> Sergey Gromov wrote:
>> Fri, 24 Jul 2009 16:58:50 -0500, Andrei Alexandrescu wrote:
>> 
>>>>>> deterministic destructors,  arbitrary copy constructors, and optional
>>>>>> lack of default constructor.
>>>>> Struct have that except for default constructor. In D, currently default
>>>>> constructors cannot execute code. This is a limitation that we might
>>>>> need to address, although it has some advantages.
>>>> There are things that copy constructors can do that the post-blit
>>>> operator can't do.
>>> Yes, mostly wrong things. I think it would be a huge loss if D copied 
>>> C++'s model.
>> 
>> This means that structs cannot hold on external resources, ever:
>> 
>>     struct RAII {...}
>>     var a = RAII("foo");
>>     var b = RAII("bar");
>>     a = b; // you just leaked a and corrupted b
> 
> You may be making a confusion between assignment and copy construction.

Sure I'm confusing them, silly me.

The only thing copy-construction is useful for is implementing move
semantics, think std::auto_ptr.  Seems like everything else can be done
in post-blit.

The inability to overload opAssign(typeof(this)) is a blocker for robust
RAII though.



More information about the Digitalmars-d mailing list