On Oct 10, 2013, at 10:43 AM, Joseph Rushton Wakeling <[email protected]> wrote:
> On 10/10/13 19:39, Sean Kelly wrote: >> As long as the reference itself can be reassigned (tail-immutable, I >> suppose) I think immutable is occasionally quite useful for complex data >> structures. It basically formalizes the RCU (read-copy-update) approach to >> wait-free concurrency. I'd tend to use this most often for global data >> structures built up on app start, and updated rarely to never as the program >> runs. > > This kind of stuff is outside my experience, so if you'd like to offer a more > detailed explanation/example, I'd be very grateful :-) Configuration data, for example. On app start you might load a config file, generate information about the user, and so on, before real processing begins. This data needs to be visible everywhere and it rarely if ever changes as the program runs, so you fill the data structures and then make them immutable. Assuming, of course, that the data structures have immutable versions of all the necessary functions (which is unfortunately a pretty big assumption).
