On Friday, 20 May 2016 at 17:35:01 UTC, Kagamin wrote:
On Friday, 20 May 2016 at 16:09:54 UTC, chmike wrote:
But I now met another error in my main(). I can't assign the immutable object to a mutable reference.

Info x1 = MyInfos.one;

Is it possible to define a mutable reference to an immutable instance ? 

Sort of possible with a library solution:

import std.typecons;
auto x1 = rebindable(MyInfos.one);

I'm a bit surprized that the language doesn't support this. We have immutable strings that can be assigned to different variables. Why couldn't we do the same with objects ?

This rebindable is not user friendly.
I really wish the user could write this

Info x = MyInfos.one;

I may achieve this if Info is defined as a struct with a single member defined as rebindable.


Reply via email to