On 2008.11.15., at 14:23, Phil Jordan wrote:

>
> Hi Attila,
>
> I can't comment on the other issues, but:
>
> Attila Szegedi wrote:
>> 2. Keyword and Ref define compareTo, but don't redefine equals (and
>> hashCode) to be consistent with it. It ain't necessarily a problem if
>> you know what you're doing, but since they're public it's usually a
>> good rule of thumb to have equals consistent with compareTo (and then
>> hashCode consistent with equals).
>
> This complaint makes no sense to me. Keywords and Refs have identity
> equality semantics. No two keywords with the same name can exist,
> therefore if two keywords are equal, they are the same object. Using a
> pointer comparison is therefore semantically correct, and has the nice
> side effect of being faster.

Yeah, you're right -- they're canonicalized, therefore it's indeed  
perfectly okay. My mistake; I didn't analyze this enough to conclude  
it's a false alarm.

> Likewise, ref compareTo is based on
> comparing the refs' unique IDs. Given that they're *unique*, two refs
> are equal iff they are identical.

That should be okay too, except I have a question: what's the role of  
the UUID in the Ref at all? As far as I can tell, no code within  
Clojure ever calls getUUID(). If that's so, then it only seems to  
serve to provide an (essentially random) sorting order. If you don't  
mind me trying your patience with stupid questions, what purpose is  
there in a sorting order based on a value of a 122-bit random sequence  
that the objects carry internally? Is it purely for the ability to use  
them as keys in a sorted map? If so, wouldn't sequence numbers  
produced from a  
java.lang.concurrent.atomic.AtomicLong#incrementAndGet() fare better  
for the purpose? (I know it's unlikely to hit the 1/(2^122) chance of  
UUID collision, but still... :-) )

Thanks,
   Attila.

> ~phil


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to