I would guess the problem is referring to T inside the deftype. This works;

(deftype T [] Object (equals [this o] (if (instance? (class this) o)
true false)))
(let [t (T.)] (.equals t t))
==> true


On Wed, Nov 3, 2010 at 12:39 PM, ka <sancha...@gmail.com> wrote:
> Clojure 1.2.0
> 1:1 user=>
> 1:2 user=>
> 1:3 user=> (deftype T [] Object (equals [this o] (if (instance? T o)
> true false)))
> user.T
> 1:4 user=> (def t (T.))
> #'user/t
> 1:5 user=> (.equals t t)
> false
> 1:6 user=> (deftype T [] Object (equals [this o] (if (= T (class o))
> true false)))
> user.T
> 1:7 user=> (def t (T.))
> #'user/t
> 1:8 user=> (.equals t t)
> true
> 1:9 user=>
>
> (doc deftype) especially says:
>> In the method bodies, the (unqualified) name can be used to name the class 
>> (for calls to new, instance? etc).
>
> Somebody on the IRC pointed out:
>>> while compiling the deftype, T resolves to a different class object (a 
>>> compiler-generated stub class) which might conflict with the special 
>>> inlining of instance?
>
> Thanks
>
> --

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to