Project

General

Profile

Bug #6068

String::Hash documentation clarification

Added by peck (Daniel Peck) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux]
Backport:
[ruby-core:42832]

Description

modified documentation for String::hash to clarify that results are not conistent across sessions and advice for if that behavior is desired


Files

Associated revisions

Revision 9802ce8b
Added by drbrain (Eric Hodel) over 7 years ago

  • object.c (rb_obj_hash): Added note that the hash value is not deterministic on Marc-Andre's suggestion. Expanded description of the purpose of the hash method. [Bug #6068]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 34769
Added by drbrain (Eric Hodel) over 7 years ago

  • object.c (rb_obj_hash): Added note that the hash value is not deterministic on Marc-Andre's suggestion. Expanded description of the purpose of the hash method. [Bug #6068]

Revision 34769
Added by drbrain (Eric Hodel) over 7 years ago

  • object.c (rb_obj_hash): Added note that the hash value is not deterministic on Marc-Andre's suggestion. Expanded description of the purpose of the hash method. [Bug #6068]

Revision 34769
Added by drbrain (Eric Hodel) over 7 years ago

  • object.c (rb_obj_hash): Added note that the hash value is not deterministic on Marc-Andre's suggestion. Expanded description of the purpose of the hash method. [Bug #6068]

Revision 34769
Added by drbrain (Eric Hodel) over 7 years ago

  • object.c (rb_obj_hash): Added note that the hash value is not deterministic on Marc-Andre's suggestion. Expanded description of the purpose of the hash method. [Bug #6068]

Revision 34769
Added by drbrain (Eric Hodel) over 7 years ago

  • object.c (rb_obj_hash): Added note that the hash value is not deterministic on Marc-Andre's suggestion. Expanded description of the purpose of the hash method. [Bug #6068]

Revision 34769
Added by drbrain (Eric Hodel) over 7 years ago

  • object.c (rb_obj_hash): Added note that the hash value is not deterministic on Marc-Andre's suggestion. Expanded description of the purpose of the hash method. [Bug #6068]

History

Updated by marcandre (Marc-Andre Lafortune) over 7 years ago

I'm not sure that all implementations have to return hash codes that differ from one run to the other. I would also modify Object#hash, as all hashes in CRuby are random seeded, not just String. I'd recommend adding the following line to Object#hash:

No other assumption can be made on hash values; in particular they may vary between sessions or implementations.

#2

Updated by drbrain (Eric Hodel) over 7 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r34769.
Daniel, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • object.c (rb_obj_hash): Added note that the hash value is not deterministic on Marc-Andre's suggestion. Expanded description of the purpose of the hash method. [Bug #6068]

Updated by drbrain (Eric Hodel) over 7 years ago

Daniel, I couldn't use your patch as it was not line-wrapped to 80 columns and was too-specific to String. As Marc-Andre pointed out, the randomization behavior applies to Fixnum, Hash, String, Symbol, Array, etc., so I applied a patch based on his suggestion.

Also available in: Atom PDF