What guarantees does D 'const' provide, compared to C++?

Mehrdad wfunction at hotmail.com
Thu Aug 16 20:44:37 PDT 2012


On Friday, 17 August 2012 at 03:42:23 UTC, Mehrdad wrote:
> On Friday, 17 August 2012 at 03:36:28 UTC, Chris Cain wrote:
>> Combine const and pure
>
>
> Yes, I 100% realize 'pure' and 'immutable' are advantages over 
> C++.
> The question was about 'const' by itself, though, because 
> otherwise that's not a fair comparison. (The goal is comparing 
> C++ const to D const, not C++ const to D const + immutable + 
> purity.)

To clarify... the motivation for this question in the first place 
was the fact that I've been consistently told (and have read) 
that D const provides more guarantees than C++ const, so I was 
trying to figure out how.


If what you're saying is that the extra guarantees only translate 
into optimizations when used along with immutable/pure, then 
that's a completely valid answer. :) Is that what you're saying?

(i.e. I DO realize that combining them would give you an 
optimization, but the question is -- must you combine const with 
something else to gain an advantage over C++?)


More information about the Digitalmars-d mailing list