[前][次][番号順一覧][スレッド一覧]

ruby-changes:22720

From: drbrain <ko1@a...>
Date: Fri, 24 Feb 2012 07:24:12 +0900 (JST)
Subject: [ruby-changes:22720] drbrain:r34769 (trunk): * object.c (rb_obj_hash): Added note that the hash value is not

drbrain	2012-02-24 07:23:58 +0900 (Fri, 24 Feb 2012)

  New Revision: 34769

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34769

  Log:
    * 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]

  Modified files:
    trunk/ChangeLog
    trunk/object.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 34768)
+++ ChangeLog	(revision 34769)
@@ -1,3 +1,9 @@
+Fri Feb 24 06:21:15 2012  Eric Hodel  <drbrain@s...>
+
+	* 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]
+
 Thu Feb 23 23:01:21 2012  Tanaka Akira  <akr@f...>
 
 	* ext/dbm/extconf.rb: unused macro removed.
Index: object.c
===================================================================
--- object.c	(revision 34768)
+++ object.c	(revision 34769)
@@ -101,14 +101,17 @@
 }
 
 /*
- * Generates a <code>Fixnum</code> hash value for this object.
- * This function must have the property that a.eql?(b) implies
- * a.hash <code>==</code> b.hash.
- * The hash value is used by class <code>Hash</code>.
- * Any hash value that exceeds the capacity of a <code>Fixnum</code> will be
- * truncated before being used.
+ * Generates a Fixnum hash value for this object.  This function must have the
+ * property that <code>a.eql?(b)<code> implies <code>a.hash == b.hash</code>.
  *
- *      "waffle".hash #=> -910576647
+ * The hash value is used along with #eql? by the Hash class to determine if
+ * two objects reference the same hash key.  Any hash value that exceeds the
+ * capacity of a Fixnum will be truncated before being used.
+ *
+ * The hash value for an object may not be identical across invocations or
+ * implementations of ruby.  If you need a stable identifier across ruby
+ * invocations and implementations you will need to generate one with a custom
+ * method.
  */
 VALUE
 rb_obj_hash(VALUE obj)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]