Const Ideas

Craig Black cblack at ara.com
Fri Nov 30 10:37:47 PST 2007


"Janice Caron" <caron800 at googlemail.com> wrote in message 
news:mailman.201.1196446640.2338.digitalmars-d at puremagic.com...
> On 11/30/07, Craig Black <cblack at ara.com> wrote:
>> Janice proposed an idea
>> for constifying instance member functions using const(this).
>
> That actually wasn't me. I like the idea (a lot), but I can't claim
> credit for inventing it.
>
> I did come up with the idea of extending it to const(identifier) though.
>
>
>> If we did this, I would suggest getting rid of the postfix syntax.
>
> I would certainly agree with that!
>
>
>> const X x;  // The data is const, the reference is mutable
>
> The problem I have with this is that I believe X should mean the same
> as (X). So if you accept that, const X x; must mean the same thing as
> const(X) x; And if you believe that const(...) has to mean "everything
> inside the brackets is const" (which is what I believe) then you have
> to conclude that const X x must mean "x is completely and absolutely
> const, and nothing about it is mutable". That's actually what it means
> right now (so long as you omit the brackets). That's why I argue that
> you need something else - something /outside the brackets/ - to mean
> "let the reference be mutable". (And obviously, that mechanism should
> only be available for reference types).

We could also add mutable(ref), but I don't think mutable is even a keyword. 





More information about the Digitalmars-d mailing list