cast(!const) proposal
Janice Caron
caron800 at googlemail.com
Tue Sep 11 11:52:50 PDT 2007
On 9/11/07, Steven Schveighoffer <schveiguy at yahoo.com> wrote:
> I don't agree.
Seems to me that you and I are actually in complete agreement. (Well,
one of my replies starts with "But" - see below).
> If we are to have pointers, then I think we are going to
> have to agree that there will be ways to do *bad* things with them.
Of course.
> I can
> think of other ways to circumvent your const rule about casting to int that
> will allow code to change const data without having to use the cast(!const).
So can I. I even gave an example on another thread, with a working demo.
> I don't think it will be possible to get around all these possibilities with
> compiler errors.
But it *will* be possible to outlaw cast(T)x, wherever T has different
const characteristics from typeof(x). As soon as the compiler sees
that, it can insist on cast(!const)x or cast(!const T)x.
> My opinion is that any time you are casting away const, you should need the
> special cast(!const).
That's what I said.
> If you are doing funky things to get around that
> rule, then you are on your own.
I said that too.
So fear not - I think we're on the same page here.
:-)
More information about the Digitalmars-d
mailing list