(hash #:x most-postive-fixnum) hashes to the same value for all keyowrds in at least 2.2 and 3.0. Here's one potential fix for 3.0, and I'd be happy to adjust it for 2.2 if needed.
>From b380102564aad053f22586eb404e99c82635a3b0 Mon Sep 17 00:00:00 2001 From: Rob Browning <r...@defaultvalue.org> Date: Sun, 16 Feb 2020 12:12:08 -0600 Subject: [PATCH 1/1] Implement hashing for keywords, i.e. (hash #:x ...) Add keyword handling to (hash ...). Previously it would just return the same value for all keywords. * libguile/hash.c (scm_raw_ihash): Add scm_tc7_keyword case. * libguile/keywords.h (SCM_I_KEYWORD_HASH): New macro. --- libguile/hash.c | 3 +++ libguile/keywords.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/libguile/hash.c b/libguile/hash.c index d6e93dae0..c51a794c9 100644 --- a/libguile/hash.c +++ b/libguile/hash.c @@ -35,6 +35,7 @@ #include "chars.h" #include "foreign.h" #include "gsubr.h" +#include "keywords.h" #include "numbers.h" #include "pairs.h" #include "ports.h" @@ -307,6 +308,8 @@ scm_raw_ihash (SCM obj, size_t depth) return scm_i_string_hash (obj); case scm_tc7_symbol: return scm_i_symbol_hash (obj); + case scm_tc7_keyword: + return SCM_I_KEYWORD_HASH (obj); case scm_tc7_pointer: return scm_raw_ihashq ((uintptr_t) SCM_POINTER_VALUE (obj)); case scm_tc7_wvect: diff --git a/libguile/keywords.h b/libguile/keywords.h index c8f480869..cb8598d8b 100644 --- a/libguile/keywords.h +++ b/libguile/keywords.h @@ -60,6 +60,8 @@ SCM_API void scm_c_bind_keyword_arguments (const char *subr, SCM rest, scm_t_keyword_arguments_flags flags, ...); +#define SCM_I_KEYWORD_HASH(x) scm_i_symbol_hash (SCM_CELL_OBJECT_1 (x)) + SCM_INTERNAL void scm_init_keywords (void); #endif /* SCM_KEYWORDS_H */ -- 2.24.1
-- Rob Browning rlb @defaultvalue.org and @debian.org GPG as of 2011-07-10 E6A9 DA3C C9FD 1FF8 C676 D2C4 C0F0 39E9 ED1B 597A GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4