Old problem with performance

Rainer Deyke rainerd at eldwood.com
Thu Feb 12 15:53:37 PST 2009


Tom S wrote:
> Rainer Deyke wrote:
>> If T was a reference type, 'c1' and 'c2' now share state, and it's up to
>> the programmer to write code to prevent this.
> 
> No, they don't. Each instance of C has its own copy of the 't' reference.

That's like saying object slicing is an intentional feature.  Given the
intended semantics of 'C', it's a bug.

>> Moreover, the D language
>> doesn't even give a hint as to whether T or a reference type or a value
>> type.
> 
> Like you can't write "typedef X* T;" in C...

The C programmer who does that should be shot.  In C++ this idiom has
some valid uses (iterators, template metaprogramming), but there remains
an important distinction: the syntax for dealing with variables of type
'X*' is different than the syntax for dealing with variables of type 'X'.


-- 
Rainer Deyke - rainerd at eldwood.com



More information about the Digitalmars-d mailing list