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

Add default constructor for Reverse{Fwd}() #37822

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

oxinabox
Copy link
Contributor

Follow up to #33736
if you have a RevereOrdering type and it has its type parameter.
Then most often it is the standard typeof(Base.Reverse) which is ReverseOrdering{ForwardOrdering}
which can be constructed as ReverseOrdering(ForwardOrdering()) == Reverse

test/sorting.jl Outdated Show resolved Hide resolved
@LilithHafner
Copy link
Member

I'm having a hard time picturing a use case for this.

@oxinabox
Copy link
Contributor Author

oxinabox commented Dec 8, 2022

It's been two years and I struggle to even remember the PR.
But it was going to let us delete this line: https://github.com/JuliaCollections/DataStructures.jl/pull/687/files#diff-e8c1224688809598c61cad8d4acf12db5a97050a610c0d7cefda0615339a2ccfR55-R57

because just like for the Base.ForwardOrdering type, one would be able to construct the instance for Base.ReverseOrdering{Forward} by just calling () on it
I think

Copy link
Member

@LilithHafner LilithHafner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems sensible; I wonder if we should support this for all singleton types

This PR is ever-so-slightly stronger than supporting T() for all singleton types T because it also supports ReverseOrdering{T} for all types T with T()defined, so it would be technically breaking to revert this should #47853 be accepted.

test/sorting.jl Show resolved Hide resolved
Co-authored-by: Lilith Orion Hafner <lilithhafner@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants