what was wrong with struct & class in C++?
Christopher Wright
dhasenan at gmail.com
Fri Dec 14 16:03:10 PST 2007
Walter Bright wrote:
> Yigal Chripun wrote:
>> for me, the distinction between PODs and "objects" should be the
>> polymorphic behavior, not the size of it (maybe i didn't explain
>> myself properly). Am i completely wrong here?
>
> You're right. Any object designed for inheritance or polymorphism should
> properly be a reference type.
Is this because it is too difficult to implement polymorphism for value
types safely and efficiently right now?
There's the slicing problem, of course, but there should be ways around
that: worst case, you could rebuild the current stack frame each time
you assign a polymorphic struct, but the effects on performance would be
unpleasant. More happily, you could handle polymorphic structs like
classes, but copy on (non-const) assignment.
That would be allowed in D, if you could overload T.opAssign(T).
More information about the Digitalmars-d
mailing list