Any plans to support STL value types?
Kagamin via Digitalmars-d
digitalmars-d at puremagic.com
Sat May 16 02:11:45 PDT 2015
On Friday, 15 May 2015 at 19:44:29 UTC, Jonathan M Davis wrote:
> So, while I don't know how we're going to be handling STL types
> (I don't even know what the current state of C++ state support
> is, since it keeps improving), I really don't see why there's
> value in supported inheritance with value types. It would just
> be begging for bugs - which is why native D types don't support
> it.
I'm talking about support for C++ idioms in frontend code, so
satisfactory interfacing with C++ can be done, native D types can
stay as they are.
C++ value types are designed to be used as value types and
usually provide automatic memory management via RAII and scoped
destruction. Without RAII you have a more serious risk of
resource leaks or code cluttered with delete operators, also
using value types as D classes results in non-idiomatic code
resembling more Java than D or C++, which can alienate C++
programmers and is confusing overall. See an example of such
code:
https://github.com/Syniurge/Calypso/blob/master/tests/calypso/qt5/qt5demo.d
Inheritance in C++ is not always for polymorphism, often it's
just functionality inheritance, so if needed slicing can be
prevented by preventing upcasts.
More information about the Digitalmars-d
mailing list