On Sat, Jun 12, 2010 at 11:21 AM, David McNeil <mcneil.da...@gmail.com>wrote:
> As near as I can tell the protocol type hints are not used in the > resulting Java interface. For example: > > (ns demo.impl.boat) > > (defprotocol Boat > (go [boat ^int distance])) You can't put type hints on protocol methods, at least as far as I could tell. You can however put type hints on methods defined with definterface. Your deftype or defrecord can them implement those methods. It's important to understand that this defines *methods* not functions. This is less than ideal but is important if you need the performance of Java methods and the ability to look up instance data very quickly (without going through keywords or field access). So you get perf at the cost of idiomatic code. Depending on your use case you could alternatively define *functions* using the new statics feature of the prim branch. This will lead to much more idiomatic code that has very, very good perf. I would take this route as long as the speed of accessing some instance data is also not a concern. An example here of type-hinting methods with definterface http://gist.github.com/420036. David -- 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