Fully transitive const is not necessary

Steven Schveighoffer schveiguy at yahoo.com
Wed Apr 2 12:39:16 PDT 2008


"Christian Kamm" wrote
>>>  class C
>>>  {
>>>   mutable int x;
>>>   void foo() const { x++; } // const but can't be pure
>>>   void bar() pure
>>>   { /* can't do anything in here you couldn't have done above */ }
>>>  }
>
> Janice Caron wrote:
>> But you could equally well write it like this:
>>
>>     class C
>>     {
>>         int x;
>>         void foo() { x++; }
>>         void bar() pure
>>         { /* can't do anything in here you couldn't have done above */ }
>>     }
>>
>> If it can change, then don't call it const. Seems a simple enough rule to
>> me.
>
> Yes, but now const's transitivity isn't a necessity for 'future
> multiprogramming features' anymore. Instead, we're discussing a const
> scheme where mutable members could be allowed, but aren't - for 
> simplicity,
> consistency or some other reason.
>
> I have not used D2 yet, so I'm not sure it is as restricting as some 
> people
> suggest. From the outside transitive const certainly looks simpler and 
> more
> useful than C++'s variant. However, if there are several genuine cases
> where escapes from transitivity would be advantageous, allowing exceptions
> should be considered.

The point of this whole thread is that exceptions ARE possible now, so why 
must they be difficult?

-Steve 





More information about the Digitalmars-d mailing list