Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-3397] Various Index types should be nested inside their Collection types #45985

Closed
airspeedswift opened this issue Dec 12, 2016 · 5 comments
Labels
affects ABI Flag: Affects ABI good first issue Good for newcomers improvement standard library Area: Standard library umbrella

Comments

@airspeedswift
Copy link
Member

Previous ID SR-3397
Radar rdar://problem/31414906
Original Reporter @airspeedswift
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Improvement, AffectsABI, StarterProposal, swift-evolution-proposal-needed
Assignee None
Priority Medium

md5: 3c83d1b6fbe2723eae39af2904d67ffe

Issue Description:

A number of collections declare a custom index type. Due to historical compiler constraints on nested generics, these are declared outside their collection types. This restriction is now lifted and they should be moved to be nested types.

For example, DictionaryIndex should be Dictionary.Index, and ClosedRangeIndex should be ClosedRange.Index.

For Swift 3 compatibility reasons, deprecated typealiases should be created. Currently, these will not be extensible if anyone is doing this (unlikely but possible), so compiler work to allow this would be required for true backwards compatibility.

@natecook1000
Copy link
Member

Type-specific iterators should probably move inside, too, unless there's another plan for them. DictionaryIterator, StrideToIterator, Zip2Iterator, etc.

@airspeedswift
Copy link
Member Author

Good point. There isn't another plan for them – in fact we want to add more (to leave open the option of customizing them for performance later). Though several of these are subject to refactoring e.g. Zip2 might become a Collection when it's zipping collections once we have conditional conformance. So this should probably wait until after that to avoid conflicts.

@bob-wilson
Copy link

@swift-ci create

@swift-ci
Copy link
Collaborator

Comment by Daniel Tull (JIRA)

I have made a commit that nests the StrideTo and StrideThrough iterators.

Tests fail in api-digester/stability-stdlib-abi.swift and api-digester/stability-stdlib-source.swift because the result of makeIterator() is different, which I suppose is to be expected. The commit also adds typealias to the current names, I imagine that to complete this work, those can be removed and tests updated for the new types.

Would this be the correct way forward? Please let me know what to do next to get this merged in.

You can see the diff of the change here: master...danielctull-forks:SR-3397.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added good first issue Good for newcomers and removed StarterProposal swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal labels Nov 11, 2022
@AnthonyLatsis
Copy link
Collaborator

Regarding the ones mentioned here:

  • DictionaryIterator was nested here
  • DictionaryIndex was nested here
  • Zip2Iterator was nested here
  • ClosedRangeIndex was nested here
  • StrideToIterator and e.g. StrideThroughIterator are still top-level and there is little if anything we can do about that at this point.

It seems none of these changes went through evolution though, so I’m dropping the label.

@airspeedswift Why were DictionaryIterator, SetIterator, etc. not deprecated and moved to migration support like others?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects ABI Flag: Affects ABI good first issue Good for newcomers improvement standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

5 participants