const?? When and why? This is ugly!
Lutger
lutger.blijdestijn at gmail.com
Mon Mar 2 14:06:23 PST 2009
hasen wrote:
> hasen wrote:
>> I haven't been following D for over a year .. now I notice there's a
>> const!!
>>
>> [...]
>
> It seems the argument is centered around making "pure functions" possible.
>
> But, surely there's a better way of doing this than borrowing const from
> C++.
Reading the docs you must have noticed the difference between C++ const and
D. In D, const and immutable are transitive, in C++ they are not. D has
immutable, C++ does not. These two are the most important concepts and make
the D design that much different, you can't seriously claim it is borrowed
from C++.
Const in C++ is (merely) a compiler aided documentation tool, whereas
const+immutable in D are the basis of a functional programming niche inside
D.
More information about the Digitalmars-d
mailing list