Vision for the D language - stabilizing complexity?
Jesse Phillips via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jul 14 09:17:19 PDT 2016
On Tuesday, 12 July 2016 at 05:15:09 UTC, Shachar Shemesh wrote:
> C++ fully defines when it is okay to cast away constness, gives
> you aids so that you know that that's what you are doing, and
> nothing else, and gives you a method by which you can do it
> without a cast if the circumstances support it.
>
> D says any such cast is UB.
>
> Shachar
Yeah C++ defines how you can modify const data after saying you
can never modify data from a const qualified access path.
§7.1.6.1/3[1]
I still haven't found someone who can explain how C++ can define
the behavior of modifying a variable after casting away const.
Sure it says that if the original object was mutable (not stored
in ROM) than you can modify it, but that is true of D as well,
but the language doesn't know the object is not stored in ROM so
it can't tell you what it will do when you try to modify it, only
you can.
1.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf
More information about the Digitalmars-d
mailing list