On 9 April 2013 17:54, Dicebot <[email protected]> wrote: > On Tuesday, 9 April 2013 at 07:52:20 UTC, Manu wrote: > >> 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. >> > > 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. >
Errrm, only globals are shared by default. Locals or allocated memory are not thread-local, can be passed wherever they want, including other threads.
