To help LDC/GDC

Dicebot m.strashun at gmail.com
Tue Apr 9 00:54:56 PDT 2013


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.


More information about the Digitalmars-d mailing list