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-3836] The SubSequence of a Range should be a Range #46421

Closed
dabrahams opened this issue Feb 2, 2017 · 5 comments
Closed

[SR-3836] The SubSequence of a Range should be a Range #46421

dabrahams opened this issue Feb 2, 2017 · 5 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. good first issue Good for newcomers standard library Area: Standard library umbrella

Comments

@dabrahams
Copy link
Collaborator

Previous ID SR-3836
Radar None
Original Reporter @dabrahams
Type Bug
Status Closed
Resolution Cannot Reproduce
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug, StarterBug
Assignee @dabrahams
Priority Medium

md5: 8d1c0acd570b0e835bd5108fb26423ab

Issue Description:

Cluttering up the type with a RandomAccessSlice<...> wrapper or whatever has no purpose.
Same goes for CountableRange as long as it's around.

Thought should be given to whether ClosedRange.SubSequence can/should be a ClosedRange or must be a Range

@natecook1000
Copy link
Member

A ClosedRange.SubSequence would need to be able to represent an empty range, so ClosedRange is out for that.

@swift-ci
Copy link
Collaborator

Comment by David Sweeris (JIRA)

Once conditional conformance hits, could we just say that SubSequence equals Optional<Self>? That way we could just make it nil for empty ranges regardless of whether `Self` can represent such a thing. What do y'all think? Is it worth bringing up on evolution?

@dabrahams
Copy link
Collaborator Author

Dave (JIRA User) No, the SubSequence type is constrained by all kinds of things that Optional<Self> can't fulfill, e.g. it needs to be a Sequence having the same Element type.

@swift-ci
Copy link
Collaborator

Comment by David Sweeris (JIRA)

Has it already been fixed? The only place I can find "typealias SubSequence = RandomAccessSlice" anywhere in the source directory is in the definition of RandomAccessSlice itself.

@dabrahams
Copy link
Collaborator Author

Yep!

(swift) print(CountableRange<Int>.SubSequence.self)
CountableRange<Int>
(swift) print(CountableClosedRange<Int>.SubSequence.self)
RandomAccessSlice<CountableClosedRange<Int>>
(swift)

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. good first issue Good for newcomers standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

3 participants