How does Rebindable suppress the compiler's optimizations for immutable?

SimonN eiderdaus at gmail.com
Sat Feb 16 06:14:48 UTC 2019


Thanks for the detailed answers!

Yes, I accept that immutable guarantees should be implemented 
only during @safe that doesn't call into @trusted.

On Friday, 15 February 2019 at 18:59:36 UTC, H. S. Teoh wrote:
> At the very least, such [union] code should be automatically 
> @system.

Sensible.

> Honestly, I'm pretty sure that Rebindable technically
> violates the type system to do what it does.

Hmm, I remember we discussed this, and I feel the same now about 
Rebindable. Either the spec gets extra rules for @trusted or 
unions, or Rebindable generates latent bugs.

> Think of immutable as hint for the programmer, not for the 
> compiler.

Right, if the compilers don't use it yet, I'm fine with that 
interpretation. It's merely strange that we have this very 
restrictive const/immutable that is advertized to help 
optimization, but then the compiler won't take advantage. Let's 
see how this develops in the long term, whether the spec gets 
clearer on the allowed optimization.


More information about the Digitalmars-d-learn mailing list