Hi,

Am Dienstag, 22. Mai 2012 09:01:31 UTC+2 schrieb Nicolas Oury:
>
>
> I think the whole thread is about the trade-off: some people complains 
> that deftype lacks features. 
>

It's not about trade-offs. It's about deftype seemingly lacking features.
 

> Another problem with extend is that you can't access your instance 
> variables with it.


Oh, you can!

user=> (deftype Foo [x])
user.Foo
user=> (defprotocol AFoo (foo [this]))
AFoo
user=> (extend-protocol AFoo Foo (foo [this] (.x this)))
nil
user=> (foo (Foo. 5))
5

The only exception is mutable fields in the type where you don't want 
uncontrolled access. There you indeed need a protocol to handle the 
synchronisation of the field access.

Kind regards
Meikel

 

-- 
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