Article about problems & suggestions for D 2.0
Kagamin
spam at here.lot
Tue Aug 30 03:53:35 PDT 2011
Mehrdad Wrote:
> I feel like you hit the nail on the head. I feel the same way about const.
>
> Transitivity is beautiful on the outside, but I can never actually get
> it working, so I just make everything non-const. I have to sometimes do
> this even in Phobos itself, because the compiler complains about
> something random caused by transitivity.
> I also fail to see what /problem/ it's trying to solve. The DigitalMars
> website simply states:
>
> "With transitivity, there is no way to have a const pointer to mutable int."
>
> But... so what? Maybe it should actually explain the benefit, since I
> can't figure it out on my own. (The related discussion on "head-const"
> and "tail-const" seems completely irrelevant to the topic."
>
> C++'s non-transitivity seems to be quite type-safe, even if unintuitive
> to the beginner (which I don't think it is). I *never* ran into issues
> with it.
In C I had to cast away const because constness is built into the struct itself - if you want the struct to be accessed as readonly. In D transitive const is transparent - you can have the save structure both readonly and mutable.
More information about the Digitalmars-d
mailing list