d future or plans for d3

Timon Gehr timon.gehr at gmx.ch
Tue Dec 20 02:50:43 PST 2011


On 12/20/2011 11:21 AM, Froglegs wrote:
>
> I've only recently tried D out, but what I'd like to see..
>
> -GC being truly optional
> -being able to specify if the standard library should use GC or not,
> perhaps with allocators
> -if D is going to have a GC, then a precise, compacting one would be
> cool, but not if it gets in the way of making the GC optional
>
>
> One thing I'm not sure about, D classes are virtual by default, but if
> you mark all functions as final does the class still contain a VFP or
> any other cruft?

The class will still have a vptr. The vtable will contain only the type 
info.

> Also why are class functions virtual by default? My experience in C++ is
> that I rarely use virtual, so I don't really understand why that is the
> default.
>

In C++, class and struct are essentially the same. In D, you use classes 
if you want polymorphism and structs if you don't need it. structs 
cannot participate in inheritance hierarchies or contain virtual 
functions. If you don't need virtual functions, you should probably use 
structs instead of classes. (you are not doing OOP anyway.)

structs don't contain a vptr.
If you want to use extensible with final methods, class C{final: /* 
method declarations */} will do the job. But it is not the most common 
case, so it should not be the default. (IIRC C# takes a different stance 
on this, they have final methods by default to force the programmer to 
make dynamic binding explicit. It has both benefits and drawbacks.)


More information about the Digitalmars-d mailing list