On Wed, 21 Sep 2011 10:15:31 -0700, Mehrdad wrote: > I can't find the thread, but I remember someone (bearophile?) mentioned > that the reason we have transitive const is to support purity. > > I don't think I understand why this is necessary, though -- could > someone please explain why we have transitive const, and what problems > it fixes? > > Thanks!
I came across this blog earlier, it may hold the answers you seek: http://www.reddit.com/tb/kkwch "One of the core difficulties in concurrent programming is trying to avoid the simultaneous reading and writing of data. Like with functional programming, concurrent programming is a lot easier when data can't change -- if you have no writes then you can't possibly have simultaneously reading and writing. However, unlike functional programming, logical const just doesn't cut it. If you were to give a reference to an instance of my Matrix class to two threads, and ask them both to compute the determinant then you could end up with an ugly race condition due to the memory writes in the caching mechanism. Here, physical immutability really does matter."