Uploaded image for project: 'Swift'
  1. Swift
  2. SR-3453

Enforce appropriate constraints on Sequences and Collections

    XMLWordPrintable

    Details

      Description

      Once it is possible in the language (dependent on associated types with where clauses and recursive protocol constraints), the following rules should be enforced:

      • Iterator should be a Sequence
      • Sequence.Iterator.Element should become Sequence.Element
      • Sequence.SubSequence must be a Sequence
      • Sequence.SubSequence.Element must be same type as Sequence.Element
      • Collection.SubSequence.Index should be same type as Collection.Index
      • BidirectionalCollection.SubSequence should be a BidirectionalCollection
      • RandomAccessCollection.SubSequence should be a RandomAccessCollection
      • RangeReplaceableCollection.SubSequence should be a RangeReplaceableCollection
      • Collection.Indices should be a Collection
      • Collection.Indices.Index should be same type as Collection.Index
      • Collection.SubSequence.Indices should be same type as Collection.Indices

      Enforcing these rules will massively simplify the writing of generic collections, including several instances in the standard library. See most entries marked FIXME(ABI) with (Associated Types with where clauses) or (Recursive Protocol Constraints) for examples.

        Attachments

          Activity

            People

            • Assignee:
              airspeedswift Ben Cohen
              Reporter:
              airspeedswift Ben Cohen
            • Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: