Fully transitive const is not necessary

Walter Bright newshound1 at digitalmars.com
Wed Apr 2 15:27:46 PDT 2008


Bill Baxter wrote:
> So const isn't a guarantee of thread safety.

You're right, it isn't sufficient. But it is necessary.


> Hey! That probably *is* thread safe, and it didn't even use const at all.

You can certainly write thread-safe code that doesn't use const at all. 
You just have to be careful not to change it - i.e. the checking will be 
  done by you, the programmer, rather than the compiler.

> I can see invariant having some value in conjunction with pure, but I 
> also suspect that invariant, being so strict, is also something that 
> will not get used a lot outside of simple constants and code carefully 
> designed for running in parallel.  Like what Don's said.

Invariant strings have turned out to be a resounding success (and I was 
very, very skeptical of that initially). I suspect that more and more 
programs will gravitate towards using invariant as people get more used 
to the idea. I know my programs will.



More information about the Digitalmars-d mailing list