Question: defrecord accessor efficiency without protocols

2014-05-16 Thread Dave Tenny
(defrecord Foo [bar])

(:bar (Foo. 1))

Is clojure smart enough to make the :bar lookup O(1) as a known field of 
Foo?  Or is it still a map-like O(logN) lookup?


-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Question: defrecord accessor efficiency without protocols

2014-05-16 Thread László Török
Hi,

afaik the Clojure compiler will compile such calls to a direct field
access, i.e. the fastest possible.
This will happen whenever the compiler can infer the type information.
You can facilitate this by using type hints if necessary.

Regards,
Las


2014-05-16 15:44 GMT+01:00 Dave Tenny dave.te...@gmail.com:

 (defrecord Foo [bar])

 (:bar (Foo. 1))

 Is clojure smart enough to make the :bar lookup O(1) as a known field of
 Foo?  Or is it still a map-like O(logN) lookup?


  --
 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
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
László Török
Checkout Lollyrewards.com http://www.lollyrewards.com - Giving credit,
getting credit.
Follow us on Twitter @lollyrewards https://twitter.com/lollyrewards
Stay up to date on the latest offers by liking our Facebook
pagehttps://www.facebook.com/lollyrewards
.

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.