On Sat, Feb 12, 2011 at 9:42 PM, Ken Wesson <kwess...@gmail.com> wrote: > Frak. I tried a cleverish way to maybe answer that question from > within Clojure, basically by seeing if a deliberately bad assignment > threw on the assignment or only when the thing got used. > > Specifically, I used this: > > (let [^String k 3] > (.length k))
Oh, and (let [^String k 3]) doesn't throw, but that doesn't tell me anything useful: the compiler could just be taking locals clearing to the extreme that the unused k is completely optimized out of existence. No assignment of 3 to k would mean no possible cast of 3 to a string and thus no exception. It wouldn't be hard to optimize that to bytecode equivalent to (do 3 nil). (Why not just nil? In case the initializer for k had side effects. Though it might know that integer literals don't have side effects and get rid of the 3 entirely and not just the creation of a local and the assignment of the 3 to it.) -- 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