what was wrong with struct & class in C++?

Bruce Adams tortoise_74 at yeah.who.co.uk
Thu Dec 13 17:07:15 PST 2007


On Thu, 13 Dec 2007 00:59:33 -0000, BC  
<NOTmi_emayl_adrez at hotmail.com.remove.not> wrote:

>
> I don't see how C++ is forcing anything. C++ is the one that gives you
> the choice. If I want two closely related types to be viewed through a
> common interface or to share implementation in D, I have to accept
> reference semantics as well, everywhere. If you have an aversion to
> by-value objects you can always stick to pointers in C++. Use an alias.
> We're not trying to take anything away, it's an addition.
>

I think the problem with C++ (problem may be too harsh) is you are forced  
to choose between
pass by reference and pass by value semantics. Though in practice you  
rarely choose value semantics.
There seems to be a lot of toing and froing over which is best.
In my opinion there should be one default calling convention and the  
compiler decides
whether to pass by reference or value as it ought to know best which will  
be more efficient.
As programmer you just want to get on and code.
Note the ought though. I think there should be an option to choose one or  
the other when you
as programmer have good reason to believe one will perform better than the  
other. I'm not sure that
D makes this easy.
The important part of the contract is whether the object passed is mutable  
or not and this is why we need const.

Regards,

Bruce. (drunk and sleepy)



More information about the Digitalmars-d mailing list