any news on const/invariant?

Janice Caron caron800 at googlemail.com
Wed Nov 28 14:15:06 PST 2007


On 11/28/07, Walter Bright <newshound1 at digitalmars.com> wrote:
> So I infer you agree that C++ is not consistent or intuitive <g>.

Of course I agree with that. How could I not!? :-)


> I don't think it adds anything but extra typing.

It adds the ability to parse the declaration differently, so that
const binds to the type, not the identifier, so while

    const(this) int[] f();

is extra typing compared with the existing syntax, it would free up
the existing syntax to mean

    const(int[]) f()


> Const is different in D than in C++, and it will take some getting used
> to for refugees from C++. Anyone who expects it to behave exactly like
> C++ will have difficulty. But if they spend a little time looking at it
> and give it a chance, I think they'll find that it is more consistent,
> intuitive, and usable than C++ const.

So, how do I declare dg to be a delegate which can call a const member function?

Would it be

    (const int delegate()) dg;

?



More information about the Digitalmars-d mailing list