const methods()

Kristian Kilpi kjkilpi at gmail.com
Tue Jan 23 09:57:36 PST 2007


On Tue, 23 Jan 2007 18:15:14 +0200, James Dennett <jdennett at acm.org> wrote:
> Kristian Kilpi wrote:
>> On Tue, 23 Jan 2007 14:52:30 +0200, Mike <mike at mike.com> wrote:
>>> Kristian, the mutable keyword allows you to override the constness. So
>>> in my
>>> opinion, the way C++ does const objects is perfect. Cant understand
>>> why its not in D.
>>
>> Wha!? I can't believe I have missed that one! 8|  Hehheh... well, you
>> learn every day something new (sometimes pretty essential things it
>> seems)... Thanks for pointing this out. :)
>
> Without wishing to pick on Kristian, this is fairly common
> of "your language sucks because..." arguments -- those who
> know the language better know the argument to be based on
> insufficient understanding, but that doesn't stop it being
> promulgated enthusiastically.  Right now this probably
> happens more to C and C++ than to any other languages
> (which isn't to say that those languages don't have
> plenty of legitimate warts), but if/when D has more success
> the D community will likely be on the receiving end of this.
>
> Learning from how this has hurt other languages could
> enable the D community to manage the propaganda war more
> effectively.
>
> -- James

Thanks (for not picking on me). Actually I have used C++ a lot and done  
preeetty big projects with it. It's amazing that I hadn't noticed the  
'mutable' keyword during all these years. When I came across a situation I  
described earlier in my example, the first thing I thought of was to do a  
nonconst cast and be done with it. That is, C++ allows you to do that. If  
nonconst casting had not been possible, then I would have searched for  
different solution, and noticed that 'mutable' exists.

But yeah, partial understanding of a language can cause "your language  
sucks" remarks. But maybe the first impression of the language wasn't the  
best possible then. For example, lisp is not for me. I mean, it's a great  
language with cool features etc, but I have found it not-so-easy to code  
with. Of course, a couple of years of hard coding with it would probably  
change that. On the other hand, some features and limitations of a  
language can begin to annoy you after a while. For instance, I have learnt  
to *hate* the header files of C and C++.

And, of course, if someone says "that sucks" without explaining why is  
that, nobody should notice that remark. I did explain what was unfortunate  
with C++ const in my opinion, and I was 'corrected' right away. <g>



More information about the Digitalmars-d mailing list