My interpretation is that the hash code issue (if correct) is an
implementation detail, and that this should indeed be considered a bug
because nil certainly seems like a compile-time literal to me. It's
also an especially useful value in the context of something like case.
In any case, thanks for
I was surprised today when using nil as the test value for one of
the clauses of the new 1.2 case statement that it results in an NPE.
Is this a bug, or intended behavior?
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send
case does constant-time dispatch using the hash codes of the test
values. Since nil is Java null, it doesn't have a hash code, so
case can't handle it.
I wouldn't call it a bug, but there is work to be done on extending
case to edge cases like this.
-S
On Aug 30, 5:07 pm, Paul Mooser
That was my first thought too, but (hash nil) is zero. So it doesn't
seem like it should be caused by that problem. I'm not familiar
enough with the internals of clojure.core to follow all of the stuff
going on in (source case), but it seems to be using (hash x) rather
than (. x hashCode). And