On Tue, Nov 24, 2009 at 1:19 AM, Krukow <karl.kru...@gmail.com> wrote: > > > On Nov 24, 4:55 am, Allen Rohner <aroh...@gmail.com> wrote: >> The first stumbling point I reached is that deftypes provide an >> automatic implementation for IPersistentMap, but not IFn. I attempted >> to write (instance key), which exploded, but (key instance) works just >> fine. My existing code uses (instance key) almost universally. Should >> I get used to this, or are there plans to provide a default IFn >> implementation? > > I agree that it would be nice with an automatic IFn implementation if > you specify the interface.
If you use a (:k x) where :k is a literal keyword for a pre-defined field of x (that is, not an entry you added to that object using 'assoc'), Clojure will tweak that particular call site to be very fast. On the other hand, if you do (x :k) or have a non-literal key such as a keyword stored in a local or var, it will not do those extra performance tweaks. I don't know if it would be possible to make (x :k) as fast as (:k x), but I sorta doubt it will happen. --Chouser -- 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