On 29/11/10 11:13 PM, Walter Bright wrote:
Peter Alexander wrote:
On 29/11/10 8:58 PM, Walter Bright wrote:
Because people coming from C++ ask "why not do it like C++'s?"
No one is asking this.
I interpreted this from Jonathon as asking for it:
"Without immutable, you could presumably get something similar
to what C++ has (if you could ever get Walter to go for it),"
You also wrote:
"I can be sure that my object will come back unmodified. That it is the
primary purpose of const. Like you said, it allows you to reason about
your programs.
Yes, GameObject could be unreasonably mutilated by careless use of
mutable, but in practice that simply doesn't happen."
Which implies that you regard C++'s system as sufficient. I pointed out
5 reasons why the "be sure" is incorrect. I believe it is necessary to
discuss and understand these points in order to justify why D does not
adopt C++'s system.
That was in response to your claim that C++'s const provides no
guarantees. I was just giving a counterexample.
Just to clarify my position
- I *do not* want to copy C++'s const system.
- D style immutability is useful.
- C++ style logical const is also useful.
- I think they can both work side by side by introducing a new level of
const and the mutable keyword.