You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The common pattern, in .NET (and it seems in Dart) is to expose the existing types and then throw exceptions in mutate operations (add, remove, clear, etc)--at least from looking at ImmutableList<E>.
This creates clutter in documentation and exceptions at runtime that could easily be resolved by the type system.
I want to expose lists, maps, and sets via properties without having to wrap everything in a wrapper and confuse my user.
Is myObject.items.clear() supported or not?
I want to accept lists, maps, and sets via method/constructor/factory paramaters with the explict promise that I intend to inspect, but not mutate the input.
why was this issue merged into #236?
that issue is entitled "Immutable List/Map". notice how the word "Set" isn't in there.
in order to mark this issue as a dup of that one, you either have to expand the scope of
that issue to include Sets (at which point it would have to be re-opened)
or you would have to un-dup this one.
at any rate, dart still doesn't have an immutable/unmodifiable Set with an interface similar to that for List and Map. e.g. dart does have UnmodifiableListView and UnmodifiableMapView, but no UnmodifiableSetView. yes, i know that there is built_collection, but i said "...with an interface similar to..." and such functionality should be equally core as UnmodifiableListView.
another example of the irregular treatment of Set: List and Map both have an unmodifiable constructor, but Set doesn't.
for reference, #11256 also requests an unmodifiable Set and it was closed as fixed, but i can't figure out why since the request in the title doesn't seem to be resolved.
I use collections (list, map, set) a lot. One of the pains of .NET is the legacy around collection interfaces: no support for immutable.
The best one gets is IList.IsReadOnly, which is too little to late.
My humble request:
ImmutableList<E>
ImmutableMap<K, V>
ImmutableSet<E>
The common pattern, in .NET (and it seems in Dart) is to expose the existing types and then throw exceptions in mutate operations (add, remove, clear, etc)--at least from looking at ImmutableList<E>.
This creates clutter in documentation and exceptions at runtime that could easily be resolved by the type system.
I want to expose lists, maps, and sets via properties without having to wrap everything in a wrapper and confuse my user.
Is myObject.items.clear() supported or not?
I want to accept lists, maps, and sets via method/constructor/factory paramaters with the explict promise that I intend to inspect, but not mutate the input.
Scala has an amazing approach here by having a whole namespace of immutable collection interfaces (and classes).
http://www.scala-lang.org/docu/files/collections-api/collections_1.html
While I’d love to have in-the-box immutable collections in Dart, I’d settle for common interfaces that serve as superclasses for the mutable versions.
While I fully support pushing off non-essential features for later, I must plead a bit here.
If v1 ships without immutable collection support, it will be prohibitive to introduce this concept later.
Help us ship better code.
The text was updated successfully, but these errors were encountered: