JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.55k stars 5.47k forks source link

AbstractOrderedDict (and AbstractOrderedSet) in Base #38141

Open PallHaraldsson opened 3 years ago

PallHaraldsson commented 3 years ago

Hi, we probably need AbstractOrderedDict <: AbstractDict, in Julia 1.6, even if my Dict change to ordered doesn't make it into Julia 1.6.

Right now AbstractDict doesn't require order, and maybe later we should change that (after packages refer to the new type).

I'm not sure we need both right away:

AbstractOrderedDict <: AbstractUnorderedDict

And I'm not changes Set, for now at least, but I guess we should similarly have AbstractOrderedSet.

KristofferC commented 3 years ago

we probably need

I don't really see why that is the case. Why is it needed?

PallHaraldsson commented 3 years ago

Wouldn't you want to have AbstractOrderedDict specified somethere (in function calls datastructures), i.e. restricting to ordered types? E.g. for the already existing once available in packages (and possibly more than those two I know of implementing ordered dicts).

At least in the future, when Dict is potentially ordered, I would find it confusing to specify AbstractDict knowing Dict is ordered, being used to maybe nothing else, with it allowing unordered.

This should I guess then go into Compat.jl, I at least see no big downside to specifying the type.

If we need it, why not here (and Compat)? Now, if we don't then please just close. Otherwise I can make a PR.

When/if Julia 1.6 will be the only LTS, this is even more helpful, being able to rely on it, and change the packages.