<lop...@gmail.com> writes: > Is it possible to use Java assertion system in Clojure? > > I want to put invariant checks in my code which can be turned on/off at > runtime with java -ea/-da. > > http://docs.oracle.com/javase/7/docs/technotes/guides/language/assert.html > > The only mention touching this issue in Clojure I could find is > > https://groups.google.com/forum/#!topic/clojure-dev/kUCVUEALmWI > > it does not give any constructive suggestions, though. > > Has anybody used this JVM facility in Clojure code? > > Thanks in advance for any of your hints!
I guess you could use the assertion status of Java to set the *assert* variable, and then just use the Clojure assert facility. Unfortunately this is a bit of a pain as there doesn't appear to be an API to check the assertion status. So, you'd need a bit of java code... static boolean assertsEnabled(){ boolean assertsEnabled = false; assert assertsEnabled = true; return assertedEnabled; } Bit ugly. -- -- 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/groups/opt_out.