A study on immutability usage

Jesse Phillips Jessekphillips+D at gmail.com
Mon Oct 1 13:48:04 PDT 2012


On Monday, 1 October 2012 at 12:28:33 UTC, bearophile wrote:
> Some quotations from the paper:
>
>>Unkel and Lam developed the term "stationary field" to describe 
>>fields which are never observed to change, that is, all writes 
>>precede all reads [for such field in all instances of the 
>>class]<
>
>>Our results from 14 Java applications indicates that 72-82% of 
>>fields are stationary<
>
>>programmers are sometimes forced (or voluntarily choose) to 
>>initialise fields late (i.e. after the constructor has 
>>completed). This prevents such fields from being marked final 
>>even when they are designed to be immutable.<

I've started to feel that when trying to be more const correct. I 
haven't put any thought in how I can/should/want to solve this or 
another related one I'm having.

I've had some containers which would be prefect as immutable, but 
there is a lot of effort to fill up all their data. The simple 
solution is to do some casting, I just haven't had time to see if 
a better design exists to create immutable and prevent mutable 
pointers. Pure doesn't work since data comes from disk.

Anyway, nice to see similar issues found in research.


More information about the Digitalmars-d mailing list