Home Dashboard Directory Help
Search

Immutable Collections by exoteric


Status: 

Active


7
1
Sign in
to vote
Type: Suggestion
ID: 585242
Opened: 8/10/2010 1:08:46 PM
Access Restriction: Public
0
Workaround(s)
view

Description

I'm repeatedly stumbling into design situations where a collection is unnecessarily mutable. It is possible to wrap a collection in an immutable wrapper but that's not a very satisfying solution, frankly, it's ugly. I have to worry about what a client could do with a collection if I exposed it. I don't want to copy it because it costs performance, I also don't want to cast it to IEnumerable because a client could still type-check, downcast to List<T> and mess it up. It's of course possible to create a state machine via the iterator mechanism but that seems superfluous just to provide safe shared access to a piece of data.

Please consider providing a well-factored high-performance immutable collections library to System.Collections[.Invariant]; with both interfaces and classes.

Not everything needs to be immutable but in many cases immutable collections is all you need and it provides both thread-safety (hello shared im-mutable state), a vastly simpler programming experience, peace of mind and who knows, maybe even the compiler writers an easier time.
Details
Sign in to post a comment.
Posted by Microsoft on 1/7/2013 at 3:41 PM
We're pleased to report we're delivering immutable collections for .NET. Please see our announcement here:
http://blogs.msdn.com/b/bclteam/archive/2012/12/18/preview-of-immutable-collections-released-on-nuget.aspx

Andrew Arnott
Visual Studio
Posted by Microsoft on 12/10/2010 at 9:03 PM
Hi exoteric,

Thanks for taking the time to suggest this. Immutable collections is something that's on our radar for the future, unfortunately, we won't be able to get to it for the next release of .NET. Therefore, I'm resolving this as Won't Fix.

Regards,

Justin Van Patten
Program Manager
Common Language Runtime
Posted by Microsoft on 8/10/2010 at 6:12 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.