Skip to content

Make superclass/interface for immutable Lists that doesn't have mutating methods instead of having throwing methods. #1869

Closed
@lrhn

Description

@lrhn

The current modelling of List uses the same supertype for "normal" lists and for immutable and fixed-length lists, just with, e.g., operator[]= and an add method that throws.

I think it would be better modelling to have a base type for indexable values without those methods, but with extended types that include the operator[]= and add methods. Something like:
  Tuple // Immutable and fixed length, has no add/removeLast or operator[]=
  MutableTuple // Fixed length, has operator[]= but not add/removeLast
  List // The current list - does it all.

("Tuple" is just a suggestion, I'm sure there are better names).

This way, a const<int>[2,4] would be a Tuple<int>, but [2,4] is a List<int>.

Something similar could be done for maps, and you probably don't even want the case where you can mutate the values but not change the keys.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.closed-not-plannedClosed as we don't intend to take action on the reported issuetype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions