Issue #16992 has been updated by Eregon (Benoit Daloze).


+1 from me. Hash if officially ordered.
Making Set unordered would likely break many things.
In practice I would think many Set usages already assume it ordered.
Similar to what I said in https://bugs.ruby-lang.org/issues/15281#note-9

Having unordered elements does not feel Ruby-like, it introduces non-determinism in things as simple as `#each`.

If super high performance is wanted and being unordered helps, then using a separate class or external gem for that makes sense I think.

----------------------------------------
Feature #16992: Sets: officially ordered
https://bugs.ruby-lang.org/issues/16992#change-87403

* Author: marcandre (Marc-Andre Lafortune)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
Officially, set elements have uncertain order. This predades when Hash started being ordered (Ruby 1.9.0, Xmas 2007). Sets have since been de-facto insertion-ordered. FYI, in those 13 years, there have been about 70 commits to `lib/set.rb`.

I have the impression that a non-negligible amount of code in the wild rely on sets being ordered, at least under most circumstances. I feel that this should be officialized.

If sets are truly unordered, then why do we hesitate to make an optimization of `&` and `|`: https://bugs.ruby-lang.org/issues/15281

See also: https://bugs.ruby-lang.org/issues/14069




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>