D const design rationale

Walter Bright newshound1 at digitalmars.com
Fri Jun 22 14:51:48 PDT 2007


Sean Kelly wrote:
> Matter of opinion, I suppose.  The C++ design was immediately clear to 
> me, though it obviously wasn't for others.  I grant that the aliasing 
> problem can be confusing, but I feel that it is a peripheral issue.

I don't think it is a peripheral issue. It completely screws up 
optimization, is useless for threading support, and has spawned endless 
angst about why C++ code is slower than Fortran code.


> Or am I missing something?

Yes, you've missed the distinction between a readonly view and a truly 
immutable value. That's not surprising, since my experience is that very 
few who are used to C++ const see the difference, and it took me a while 
to figure it out.



More information about the Digitalmars-d mailing list