Transitive const sucks

James Dennett jdennett at acm.org
Wed Sep 12 22:08:07 PDT 2007


Walter Bright wrote:
> Janice Caron wrote:
>> I was trying to simplifly. Sigh. The gist of this particular example
>> is that have what /starts off/ as perfectly good, non-member-modifying
>> code, and all is well. But then you later put in some diagnostics to
>> make it write stuff to a file (coz you're debugging) and suddenly it
>> no longer compiles and you have keep taking const out of your code all
>> over the place until it does.
> 
> Or you can cast away const-ness. But you are on your own if you do that.

Well, in C++ you'd be fine, but in D I thought the behavior
if you modified something after casting away const was
undefined, so you're out of luck.  (Not that you'd need
to cast away const for this in C++.)

-- James



More information about the Digitalmars-d mailing list