Re: JVM assertions in Clojure

2013-10-23 Thread lopusz
Clearly, global overhead of assertions depends on number and type of invariants that you check. My experience was simliar to Paul's. Compililng/disabling the assertions away helps a great deal in many cases. Paul ! I've started using pjstadig.assertions and it works like a charm :) **Thank you

Re: JVM assertions in Clojure

2013-10-15 Thread Phillip Lord
Paul Stadig writes: >> I think that you are worried about the overhead unnecessarily, though. >> The assert status is checked at macro expansion time. If per module >> switching on and off is what then I would suggest that you build on top >> of the existing assert. >> > > There is a huge performa

Re: JVM assertions in Clojure

2013-10-14 Thread Paul Stadig
So it turns out it is possible to have runtime disabled assertions in Clojure without a compiler change, but I don think it is possible to have assertions that can be disabled per package without a compiler change (if at all). I have released a new library that allows you to globally enable/disabl

Re: JVM assertions in Clojure

2013-10-14 Thread Paul Stadig
On Mon, Oct 14, 2013 at 5:59 AM, Phillip Lord wrote: > writes: > > Same trick as > Java -- optimise the check away at compile time. > > Indeed, this is how Clojure's assert works. > This is the way Clojure's assert works (by compiling away the assertion). This is not the way Java assertions work

Re: JVM assertions in Clojure

2013-10-14 Thread Phillip Lord
writes: > Phillip, Paul - thanks a lot for you suggestions! > > Phillip - I will definitely give your trick a try. > > Right now, without experimenting, I see two shortcomings. First, as Paul > mentioned, checking assertion status via call to Java function will > introduce performance penalty,

Re: JVM assertions in Clojure

2013-10-11 Thread lopusz
Phillip, Paul - thanks a lot for you suggestions! Phillip - I will definitely give your trick a try. Right now, without experimenting, I see two shortcomings. First, as Paul mentioned, checking assertion status via call to Java function will introduce performance penalty, whereas the use of pu

Re: JVM assertions in Clojure

2013-10-11 Thread Paul Stadig
As reflected in the linked discussion and Jira ticket, it seems possible to be able to use -ea/-da with Clojure. It would definitely require a compiler change, and I'm not aware of any further movement to make Clojure's asserts use a mechanism compatible with -ea/-da. An additional annoyance (a

Re: JVM assertions in Clojure

2013-10-11 Thread Paul Stadig
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

Re: JVM assertions in Clojure

2013-10-11 Thread Phillip Lord
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 Cloj

JVM assertions in Clojure

2013-10-10 Thread lopusz
Dear All, 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