Why simple code using Rebindable doesn't compile ?

chmike via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 30 22:31:59 PDT 2016


On Monday, 30 May 2016 at 21:32:46 UTC, Alex Parrill wrote:
> On Monday, 30 May 2016 at 10:09:19 UTC, chmike wrote:
>>
>> Why can't info() return a Rebindable!(immutable(InfoImpl)) ?
>
> What do you mean? `info` returns an `immutable(InfoImpl)`, not 
> a `Rebindable!(immutable(InfoImpl))`. Rebindable doesn't apply 
> itself to the return types of the methods of the return types 
> (there's no reason to).

I mean that if I change the return type of info() into 
Rebindable!(immutable(infoImpl)) like this

Rebindable!(immutable(InfoImpl)) info() { ... return 
rebindable(x);}

I get an error. I was explained privately that its because 
Rebindable... Is an lvalue and not a type.

My conclusion is that rebindable is not a satisfying solution to 
have mutable references to immutable objects.

I don't understand the rationale of these immutable references. 
It is too constraining.



More information about the Digitalmars-d-learn mailing list