Sugestion for a const implementation
Andrei Alexandrescu (See Website For Email)
SeeWebsiteForEmail at erdani.org
Wed Jan 24 12:09:52 PST 2007
Miles wrote:
> Andrei Alexandrescu (See Website For Email) wrote:
>> That's pretty limiting; you can't define something a la STL begin() that
>> returns different objects depending on the object's mutability.
>
> This is almost prejudice against const. You broke my message in this
> point just to argue against it, without considering the explanation that
> follows.
>
> If you think just a little about the solution, you will see that the
> solution cames immediately. iterator<> and const_iterator<> will became
> the exact same class, with no distinction between const and non-const.
I broke the message because it was long, having some content that I
agree with (as in "true but uninteresting"). If you get to work out on
an actual design for your idea, you will just see how it does not work.
>> Littering declarations is objective. In C++ const is never deduced, only
>> checked. The underlying vision is that there should be cases in which
>> constness is deduced such that programmers can benefit of it without
>> having to babysit the compiler.
>
> I don't share your vision. Doesn't make any sense the compiler deduce const.
Well this is simply wrong, and fortunately there's no need for an
explanation because there is plenty of previous work on qualifier
inference (http://www.cs.umd.edu/~jfoster/papers/pldi99.pdf and
Faehndrich follow-up work). Walter and I already discussed a number of
workable instances of const deduction.
Andrei
More information about the Digitalmars-d
mailing list