On 9/23/2011 3:56 PM, Jonathan M Davis wrote:
The complaints have generally been about the lack of logical const and the inability to cast away const and modify variables _not_ about transitiveness. I'm not say that there have been _no_ complaints about the transitiveness about const, but I can't recall even _one_ issue with it at the moment. It's the lack of logical const that's generally complained about and has shown itself to be a major blocker for const in some cases. - Jonathan M Davis

But the only reason logical const is an issue is indeed the fact that const is transitive.

To illustrate, I run into problem almost every other time I use D, and to me it's *only* a problem because source is const:

class MyRange : InputRange!char
{
     char peeked;
     InputRange!char  source;
     char front() const
     {
         // How do I lazy-load the value?
         if (peeked == '\0')
         {
             peeked = source.front;
             // ERROR, popFront isn't const...
             source.popFront();
         }
         return peeked;
     }
}

If this isn't because of transitivity, then what is it? If only source wasn't implicitly const (and it wouldn't be in C++, since it'd be a const pointer to a non-const object) then this would be a piece of cake.

I run into this problem and similar ones so often that it's driven me away from D, as much as I was a fan. If you have a nice solution then please let me know.

Reply via email to