Immutability and other attributes, please review

Roman D. Boiko rb at d-coding.com
Thu Jun 14 06:26:20 PDT 2012


On Thursday, 14 June 2012 at 12:47:34 UTC, Roman D. Boiko wrote:
> On Thursday, 14 June 2012 at 11:11:57 UTC, Jonathan M Davis 
> wrote:
[...]
>> - Jonathan M Davis
> OK, clear. Thanks!
[...]

I've tried to convert return types of all functions to immutable 
to prevent the need for casting: 
https://github.com/roman-d-boiko/functional-data-structures/commit/98c317b59b329fe06ffae4fc4c4ab338541e3321

I would be more happy to have them mutable with immutable fields. 
But since I return data stored in the immutable field, I had to 
cast away immutable before returning, and cast to immutable in 
constructor, so I gave up.

But now, with everything immutable, I had to comment out several 
test cases. I cannot pass an immutable struct allocated on stack, 
into a method by reference, and then store a pointer to it, 
because compiler says it is not an l-value. Should I allocate it 
on heap? Or get rid of functions taking parameter by ref, and use 
only those which take a pointer?


More information about the Digitalmars-d-learn mailing list