Even more interesting is the behavior of contains? when passed strings: user=> (contains? "foo" \o) false user=> (contains? "foo" 2) true user=> (contains? "foo" 3) false user=> (contains? 'foo 2) false
It seems to treat strings as it does vectors, seeing if an index is in bounds or not. It doesn't treat symbols as anything though. The clojure.contrib.seq-utils/includes? function gives true for "foo" and \o, so it seems to recognize strings as collections (probably because they're seqable). On the matter of efficiency vs. error-catching, perhaps one can have one's cake and eat it too? How about adding a throw-if! macro to the language that checks, at macroexpansion time, if it's in debug mode and if not emits no code, but if so emits (if ~cond (throw (new ~exception-class ~message))). (It looks like a macro that expands to nil emits no code, and also doesn't screw things up in any way, anyway.) How to decide "if it's in debug mode" though? Some global binding check? Of course, there's also the issue that to turn on or off error-checking in library functions would require recompiling the library. Perhaps what's really needed is a new special form, one which emits the same bytecodes as Java asserts when compiled, and thus can be turned on or off at runtime in the same way, without recompiling anything (only reloading affected classes). --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---