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

2019-02-15 Thread SimonN via Digitalmars-d-learn
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.

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

2019-02-15 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Feb 15, 2019 at 03:50:33AM -0700, Jonathan M Davis via Digitalmars-d-learn wrote: > On Friday, February 15, 2019 3:06:34 AM MST Kagamin via Digitalmars-d-learn > wrote: > > Union is just a pretty cast, type system guarantees don't hold for > > it. > > Well, technically, what's supposed

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

2019-02-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, February 15, 2019 3:06:34 AM MST Kagamin via Digitalmars-d-learn wrote: > Union is just a pretty cast, type system guarantees don't hold > for it. Well, technically, what's supposed to be the case is that when you cast, the type system guarantees still hold but it's up to the

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

2019-02-15 Thread Kagamin via Digitalmars-d-learn
Union is just a pretty cast, type system guarantees don't hold for it.

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

2019-02-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, February 14, 2019 11:59:31 PM MST Stefan Koch via Digitalmars- d-learn wrote: > On Thursday, 14 February 2019 at 23:55:18 UTC, SimonN wrote: > > std.typecons.Rebindable!(immutable A) is implemented as: > > private union { > > > > immutable(A) original; > > A

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

2019-02-14 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 14 February 2019 at 23:55:18 UTC, SimonN wrote: std.typecons.Rebindable!(immutable A) is implemented as: private union { immutable(A) original; A stripped; } ...@trusted assignment operators... @property inout(immutable(A)) get() @trusted pure

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

2019-02-14 Thread SimonN via Digitalmars-d-learn
std.typecons.Rebindable!(immutable A) is implemented as: private union { immutable(A) original; A stripped; } ...@trusted assignment operators... @property inout(immutable(A)) get() @trusted pure nothrow @nogc inout { return original; }