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++.
At the moment Calypso maps C++ POD records to D structs, and
non-POD ones to D classes. But then it's true that this creates a
conundrum because I can't translate class value types to D types,
so currently functions that expect class value arguments are
ignored.
Making C++ classes value types would have lots of implications,
so the way I see it (for now, not sure if that's the best
solution) I'll probably stick to D class semantics but I'll have
to create C++-specific class value types to map C++ fields or
functions that take class value arguments.