unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Hash values of symbols: why look at the name?
@ 2014-09-16  0:19 Daniel Colascione
  2014-09-16  3:00 ` Stefan Monnier
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Colascione @ 2014-09-16  0:19 UTC (permalink / raw)
  To: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 817 bytes --]

Right now, this form always evaluates to t:

  (eql (sxhash (make-symbol "a")) (sxhash (make-symbol "a")))

This form always evaluates to nil:

  (equal (make-symbol "a") (make-symbol "a"))

The hash of a symbol is the hash of its namel; that seems silly, since
symbol equality is based on identity. We should be able to just use the
symbol address instead, right?


=== modified file 'src/fns.c'
--- src/fns.c	2014-09-15 05:09:44 +0000
+++ src/fns.c	2014-09-16 00:14:52 +0000
@@ -4482,13 +4482,10 @@
       break;

     case Lisp_Misc:
+    case Lisp_Symbol:
       hash = XHASH (obj);
       break;

-    case Lisp_Symbol:
-      obj = SYMBOL_NAME (obj);
-      /* Fall through.  */
-
     case Lisp_String:
       hash = sxhash_string (SSDATA (obj), SBYTES (obj));
       break;



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Hash values of symbols: why look at the name?
  2014-09-16  0:19 Hash values of symbols: why look at the name? Daniel Colascione
@ 2014-09-16  3:00 ` Stefan Monnier
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2014-09-16  3:00 UTC (permalink / raw)
  To: Daniel Colascione; +Cc: Emacs developers

> The hash of a symbol is the hash of its namel; that seems silly, since
> symbol equality is based on identity.  We should be able to just use the
> symbol address instead, right?

Sounds right,


        Stefan



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-09-16  3:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-16  0:19 Hash values of symbols: why look at the name? Daniel Colascione
2014-09-16  3:00 ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).