The problem is that you would still have a performance hit. As I 
understand, the reason that Java assertions have no runtime penalty when 
disabled is because they depend on the value of a final field in a class 
which the JIT will eliminate as dead code when that final field is set to 
false. The only way to get Clojure's asserts eliminated at runtime would 
seem to require a compiler change.

Paul

On Friday, October 11, 2013 7:02:24 AM UTC-4, Phillip Lord wrote:
>
> <lop...@gmail.com <javascript:>> 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.

Reply via email to