Logical const
Bruno Medeiros
brunodomedeiros+spam at com.gmail
Thu Dec 2 10:55:14 PST 2010
On 28/11/2010 14:50, Peter Alexander wrote:
> 1. I have to change getWorldTransform to be a non-const function that
> returns a non-const Matrix.
>
> 2. renderGameObject needs to be changed to receive a non-const GameObject.
>
> 3. I have lost any guarantee that rendering my GameObjects won't destroy
> them...
>
> Surely I'm not the only person that finds something *incredibly* wrong
> with this!?
Indeed, you should not try to use D's const for the use-case of logical
const. Rather, logical const is simply not supported, on a static type
level.
But why is that such a big problem actually? A lot of other languages
(Java, C#, etc.) have no support at all for something like logical
const, and yet are consider generally much safer than C++. Why didn't
they add logical const? Similarly for D, D has a lot of features that
generally make it safer to program in C++ (with the same level of
performance), such that in total they more than compensate for the lack
of logical const. That is no good reason to not use D.
--
Bruno Medeiros - Software Engineer
More information about the Digitalmars-d
mailing list