Const Ideas

Craig Black cblack at ara.com
Mon Dec 3 07:21:51 PST 2007


"Janice Caron" <caron800 at googlemail.com> wrote in message 
news:mailman.227.1196693680.2338.digitalmars-d at puremagic.com...
> On Dec 3, 2007 2:34 PM, Craig Black <cblack at ara.com> wrote:
>> I guess using X and Y is bad since you assume they are both types..
>> Am I wrong in assuming the following?
>>
>> const X* x;
>>
>> is not equivalent to
>>
>> const(X)* x;
>>
>> Thus const X is not always equivalent to const(X)
>
> OK. Start again, You've misunderstood me. My X stands for /everything
> between the word const and the identifier being declared/. (Not
> literally the symbol "X").
>
> So I would want "const X* x" to be interchangeable with "const(X*) x",
> since, in this case, /everything between the word const and the
> identifier being declared/ is "X*".

Right!  And the same principle can be applied to references as well.

So "const X x;"  could be interpreted to be interchangeable with "const (X 
x);"  (even though technically the latter that will not compile).

Thus your const X == const(X) rule holds with "const(X) x;" and "const X x;"






More information about the Digitalmars-d mailing list