On Tuesday, 9 April 2013 at 07:52:20 UTC, Manu wrote:Don't forget, D variables are thread-local by default. If you get a const variable that is not shared or __gshared, compiler can safely assume that it will never change in this scope.
But that's meaningless though, because there's always the possibility that
something somewhere else may have a non-const reference to that thing.
Can you suggest a case where const could EVER be used in any sort of
optimisation?
I don't think const can possibly offer anything to the optimiser in any
language, only type safety... I'd love to be wrong.