optimized immutable containers

finalpatch fengli at gmail.com
Tue Jul 2 17:55:47 PDT 2013


Is anyone aware of the new immutable containers in .Net framework?
http://blogs.msdn.com/b/bclteam/archive/2012/12/18/preview-of-immutable-collections-released-on-nuget.aspx.

While we can attach the immutable qualifier to any D containers, 
they will not perform nearly as well because they are essentially 
mutable structures. Making them immutable doesn't change the way 
they work, it merely forbids us to call the modifying methods. 
Every time we need to modify them we have to copy the entire 
thing which is not very efficient.

The .Net immutable containers are specially optimized so that 
they share the underlying data as much as possible. Creating a 
modified copy is cheap, usually O(1) or O(logN).

I think having something similar in D would make immutables much 
more attractive.


More information about the Digitalmars-d mailing list