Reddit: why aren't people using D?

Rainer Deyke rainerd at eldwood.com
Thu Jul 23 13:30:13 PDT 2009


Andrei Alexandrescu wrote:
> Rainer Deyke wrote:
>> Yes, C++ has problems, but these problems can be fixed!
> 
> How? Minding constantly a set of dangerous problems is not fixing it.

Proposal 1: instances of polymorphic classes are stored on the heap but
treated as value types.  They are copied when the variable is copied (a
full non-slicing copy), they are destroyed when the variable goes out of
scope.  In short, they are truly polymorphic value types, with some
performance penalty.

Proposal 2: Syntactically distinguish between polymorphic references
(references to an instance of a  class or any of its subclasses) and
non-polymorphic references (references to an instance of a specific
class and only that class), with the latter decaying to the former.
Copy constructors would take a non-polymorphic reference as argument,
thereby completely fixing the slicing problem.

>> The
>> struct/class split, on the other hand, introduces many more problems
>> that are harder to fix.
> 
> Again: what are those problems?

Syntactic ambiguity.  Confusion between an instance of a class and a
reference to that instance.


-- 
Rainer Deyke - rainerd at eldwood.com



More information about the Digitalmars-d mailing list