On Tuesday, 23 December 2014 at 15:20:18 UTC, Kagamin wrote:
On Monday, 22 December 2014 at 23:14:44 UTC, Elie Morisse wrote:
• Structs
https://github.com/Syniurge/Calypso/blob/master/tests/calypso/showcase.d


testClass cls = new testInherit;

This should be written

testClass* cls = new testInherit;

In C++ struct and class differ only in symbol mangling. They are both value types, support inheritance, copy constructors etc. By looking at the declaration you can't decide if a class should be used as value type or reference type, so better treat it as value type like in C++.

Ah and you're right that this might confuse the user since he has to know whether the class/struct is POD or not to know whether to use values or references. Hmm.. also simply adding a virtual function to a C++ class would break the D code which previously considered that class POD :)

So maybe you're right, it might be a better idea to make C++ classes values.

Reply via email to