Suggestion: object const'ness

ChristopheBourez ChristopheBourez_member at pathlink.com
Sun May 21 12:21:51 PDT 2006


In article <e4q2jv$2pil$1 at digitaldaemon.com>, Hasan Aljudy says...

[...snip...]

We are not advocating in favour of C++. There are some idioms independent of the
language. OOP is one, generics/template is another, RAII and so on (all present
in C++). The only thing we are trying to explain is that there is also the
const'ness concept. And it should be good to think about it. And nobody says
that this concept must be implemented the same way as it was in C++.


>> 
>> I know that Derek. Just that *many* of the users that come to D, don't 
>> know if you realize it, comes from the C++ world. It's understandable, 
>> we like the features of C++ but hate the syntax (and other stuff) and we 
>> see D as a better C++. It's perfectly natural to try to achieve the same 
>> things in D that we've achieved in C++. Don't be afraid, I'd hate to see 
>> D become another C++ (and that's not gonna happen for sure).

Thank you, Tom, it is well summarized.

>> 
>> For C++ users, 'in' parameters (for references) are 'const Obj &o', 
>> inout/out parameters are 'Obj &o'. When you see that on a signature you 
>> can be "sure" (there's always some reasonable trust in the middle) the 
>> function will not modify the object (you don't care about the object 
>> reference). In D in/out/inout are just a disappointment (for C++ users). 
>> I've dreamed to see that keywords used with the same meaning as what 
>> I've mentioned above.
>> 

[...snip...]

>"D is not C++" implies the following:
>Don't try to achieve things the same way as in C++!!
>
>It's not just the syntax that's different, it's a lot of features too.
>For example: objects are always by reference, never by value.
>This make for a huge difference; it results in a completely different 
>behaviour in many situations. (for the better).

A good C++ programmers already used "objects by reference ala Java": it is a
little bit different and sometimes(often?) called boost::smart_ptr<T>. Don't
think that C++ programmers are writing always bugged code.

>
>I would advice you to try Java for a while, maybe it can help you get 
>rid of useless C++ idioms. :)






More information about the Digitalmars-d mailing list