by pcwalton · 9y ago · 0 comments
See this article for how it's done in LLVM: http://blog.llvm.org/2009/12/introduction-to-load-eliminatio...
var x Int
// Pass x to a thread by reference
x = 0
time.Sleep(1000)
x = 1So threads never seeing the value is already a valid outcome, so the compiler might as well always do that.
For languages with less sophisticated type systems you get a choice between inefficiency (Go), or complicated rules which state that the programmer is wrong for coding that way (C).
In general I don't think Rust actually adds much abstraction that isn't already in say Python. What it does is enforce tight constraints.