Walter: Before you go and implement the new RAII syntax..

Kristian kjkilpi at gmail.com
Thu Sep 7 01:11:52 PDT 2006


On Thu, 07 Sep 2006 02:44:43 +0300, Garett Bass  
<garettbass at studiotekne.com> wrote:
[snip]
> It is unfortunate that true stack object instances do not exist in D.   
> The 'stack' syntax defies D's current heap-only object allocation  
> philosophy.
>
> Another advantage of C++ style stack object instances is the ability to  
> overload the assignment operator, which allows an object instance to be  
> treated as a built-in type.  You can't do this in D because it would  
> alias your ability to reassign the object reference to another object.   
> C++ has no problem implementing real and imaginary numbers as classes,  
> they need not be built-in types since their instances can be treated as  
> such syntactically.
>
> I don't understand why modern high-level languages are so quick to  
> discard (or bias against) the pointer.  The distinction between object  
> references/pointers and object instances is very valuable in C++.  It  
> can be nice to know that no other code is going to reassign another  
> object to your variable.
>
> Pissing in the wind,
> Garett


Now I know why D feels a bit strange at time to time. I wasn't fully aware  
of it until Garett pointed it out. And that's unability to create build-in  
types with classes. :|

I'm used to have my objects 'moduled', i.e. assigning X to Y and then  
changing Y won't change X. And there is no 'const' type... Time will tell  
how many errors I will make when handling my objects around... until I  
fully grab the concect of using references/pointers only.

Hmm, it's also 'interesting' to see how much dupping I will need. But  
dupping doesn't create deep copy, erh...


Should there be a 'physical' object instance class in D after all?



More information about the Digitalmars-d mailing list