4 ms·
I thought a lot about what to do about volatile when designing D. volatile is deeply embedded in the C++ type system, and is a very semantically expensive featu
by WalterBright 7y ago
I thought a lot about what to do about volatile when designing D. volatile is deeply embedded in the C++ type system, and is a very semantically expensive feature for what seems like little gain.
The solution was to replace volatile with a compiler intrinsic load and an intrinsic store. Those get special treatment in the code generator, and the rest of the type system does not have to carry the burden.
https://dlang.org/phobos/core_bitop.html#.volatileLoad https://dlang.org/phobos/core_bitop.html#.volatileLoad
- kibwen 7y agoIndeed, exposing volatile read/write as library operations rather than making volatility be an intrinsic property of a variable via the type system is also what Rust settled on.