On Sunday, 8 December 2013 at 12:35:45 UTC, ponce wrote:
1. D knows when data is immutable. C has to always make worst
case assumptions, and assume indirectly accessed data mutates.
ICC (and other C++ compilers) has plenty of way to disambiguate
aliasing:
- a pragma to let the optimizer assume no loop dependency
- restrict keyword
- /Qalias-const: assumes a parameter of type pointer-to-const
does not alias with a parameter of type pointer-to-non-const.
- GCC-like strict aliasing rule
To be fair, all of these are unsafe optimizations. You only use
them after carefully identifying the hot spot. D immutability is
based on a (probably) sound type system and can be used without
danger.