On Saturday, 21 May 2016 at 10:42:13 UTC, chmike wrote:
source/app.d(23,27): Error: cannot implicitly convert expression (one) of type immutable(Obj) to app.Info
Apparently Rebindable doesn't support polymorphism. This is hopefully fixable.
source/app.d(43,5): Error: 'x1' must be of integral or string type, it is a app.Info source/app.d(45,10): Error: cannot implicitly convert expression (one) of type immutable(Obj) to app.Info
A Rebindable variable can't be used as a switch argument. This would require a change to the language rules. However, the static immutable object Infos.one can be used as a case argument.
The conclusion is that Rebindable doesn't cover the needs of a mutable object reference.
In the flyweight pattern we only need to compare object addresses and we also want to use the lazy pattern to instantiate the immutable instances.