Head Const

Laeeth Isharc via Digitalmars-d digitalmars-d at puremagic.com
Wed Feb 17 23:28:20 PST 2016


On Wednesday, 17 February 2016 at 17:47:02 UTC, Jonathan M Davis 
wrote:
> On Wednesday, 17 February 2016 at 17 you're not actually 
> getting.
>
> But in practice, it does prevent accidental mutation, and as 
> long as the programmer is behaving themselves reasonably well,

>
> Unfortunately, the net result is that while const is still very 
> useful, there are a lot of cases in D where you can't use it, 
> and you have to be a lot more careful about how and when you 
> use it such that it gets used far less than in C++, and while 
> where it _is_ used does provide much better guarantees, you 
> lose out on a lot of protection against accidental mutation 
> that your typical C++ code gets.

Things would be a bit friendlier for newcomers if the 
documentation were a bit clearer on the 'having to be a lot more 
careful on how and when you use it' so one doesnt end up finding 
this out the hard way.






More information about the Digitalmars-d mailing list