schani/clojurec — pull request #6 by jolby (2012-07-24 01:19:46+00:00)
Title: Schani tracker

Hi Mark,

Thanks for the review of the hashing code earlier today. This is the latest I have for implementing IHash + assorted type specific hashing functionality. You were correct that my hashing code you reviewed was incorrect in a few spots. What I had intended was that I hash the address of the value_t object, not some X range of bytes of the value_t struct. I've fixed that. So, basically, I'm trying to follow java/jvm-clojure hashing semantics as much as possible. My understanding is that the default object case uses some hash based on the address of the object, so that is covered by the murmurhash+hash primitive function. Then for strings, you compute the hash as following: s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1] - so that is implemented in the string_hash_code function. For integers and characters, you simply use the numeric code for itself. Nil and empty collections get hash of 0. Boolean true gets hash of 1, all else 0.For hashing collections, I've added the macros/fns from clojurescript pretty much verbatim.

Anyhow, that's basically what I have in this patch, but I also have the bitwise-fns and a bugfix for bit-shift-left/right. If you want me to remove that to get a cleaner patch just let me know.

Thanks,
Joel