Simple immutable example doesn't work - why???

Rene Zwanenburg renezwanenburg at gmail.com
Wed Nov 13 15:47:09 PST 2013


On Wednesday, 13 November 2013 at 01:40:27 UTC, Louis Berube 
wrote:
> Thanks to both TFF and Kenji for their excellent explanations. 
> I think my head is going to explode ;).
>
> So, as I understand it, there are two sorts of immutable 
> entities in D.
>
> The first is probably the one most familiar to the majority of 
> us, which is an entity with immutable contents but with mutable 
> binding. This is what TFF illustrated so well in his post above 
> and what we are all familiar with as "string".
>
> The second will take me longer to get used to, which is an 
> entity with immutable contents *and* with immutable binding. 
> This is what I tripped over in my example and what Kenji 
> adroitly showed how to deal with in his post.
>
> Does this correctly sum up what I have read? If so, this 
> conversation has cleared up a great deal of my misunderstanding 
> of how "immutable" works. It would be great to see the above 
> examples in a D reference or tutorial (maybe the second edition 
> of Andrei's book?).
>
> Many thanks.

There's a Rebindable template in Phobos which I think does what 
you want:
http://dlang.org/phobos/std_typecons.html#.Rebindable


More information about the Digitalmars-d-learn mailing list