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
Need to note unordering-ge for Map/Hash/QuantHash/Bag/Set/Mix/BagHah/SetHash/MixHash #2174
Comments
Given that Rakudo used to randomize Hash keys on purpose back when we used an ordered implementation, I think we can assume that the intent is for Hash types not to preserve order. |
Given it's security that is driving the randomization, it might be reasonable for the spec to guarantee it. |
From my perspective: Hashes are not guaranteed to retain order, in fact the user should not expect it to. But I also don't think that we should have the spec guarentee that it is randomized. I see it as an implementation detail. Essentially the issue that randomization solves for us is revealing information about how the hash is laid out in memory and which hashes end up in which buckets. If an attacker can know insertion order (which we assume they know since they are inserting keys) plus the order of iteration, they can figure out which items are in the same buckets. Whereas if an implementation retained insertion order then iteration order would only reveal insertion order which an attacker would already know (they are the one inserting the keys). So things must either be ordered by either insertion order, or sufficiently randomized. In between reveals information we don't want to provide. Both ruby and python in their latest versions have an implementation that retains insertion order. Although it is not quite as fast as an implementation that does not worry about insertion order, we should keep in mind that there may be VM's/runtimes Perl 6 may run on and they may have insertion order retention. |
The title of this issue is confusing (what does "unordering-ge" mean?). Anyway, here's what I found after a quick skim of the docs:
|
Turning it into a noun, just "the fact that it is not ordered." (I would have used -age, like package) |
I don't know if the spec guarantees that the hashy types are unordered, but that info should probably mentioned (if it's not part of spec, then maybe say that some implementation keep it unordered?)
Also, it should be noted somewhere that some methods like
.Str
,.gist
, and.perl
do sort the hashy type (this is only partially implemented by Rakudo; filed as R#131244).The text was updated successfully, but these errors were encountered: