Re: error-on-reflection

2013-12-10 Thread Phillip Lord

I wasn't and this is actually very useful. Thanks for the pointer.

"John D. Hume"  writes:

> Are you aware of `lein check`? We have our some of our CI builds wired to
> fail if that finds anything.
> On Dec 9, 2013 4:12 AM, "Phillip Lord"  wrote:
>
>>
>> I know about *warn-on-reflection* but is there anyway that I can get an
>> error-on-reflection instead?
>>
>> I've been type hinting my application (50% done and yes it goes faster
>> now), and it's a bit painful. What I would really want is to have a unit
>> test which fails if reflection is used.
>>
>> So far, my best idea is catching standard-out and parsing it for
>> reflection warnings. Not ideal.
>>
>> Phil
>>
>> --
>> --
>> 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.
>>
>
> -- 

-- 
Phillip Lord,   Phone: +44 (0) 191 222 7827
Lecturer in Bioinformatics, Email: phillip.l...@newcastle.ac.uk
School of Computing Science,
http://homepages.cs.ncl.ac.uk/phillip.lord
Room 914 Claremont Tower,   skype: russet_apples
Newcastle University,   twitter: phillord
NE1 7RU 

-- 
-- 
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.


Re: error-on-reflection

2013-12-10 Thread Phillip Lord

Perfect -- I can use lein check interactively, and this in my unit
tests. It's a shame *warn-on-reflection* doesn't take a function, which
would be the general solution.

Phil

Tassilo Horn  writes:
> phillip.l...@newcastle.ac.uk (Phillip Lord) writes:
>
>> I know about *warn-on-reflection* but is there anyway that I can get
>> an error-on-reflection instead?
>
> I don't think so.
>
>> I've been type hinting my application (50% done and yes it goes faster
>> now), and it's a bit painful. What I would really want is to have a
>> unit test which fails if reflection is used.
>>
>> So far, my best idea is catching standard-out and parsing it for
>> reflection warnings. Not ideal.
>
> clojure/test/clojure/test_helper.clj already contains some helper macros
> for doing that, e.g., `should-not-reflect`:
>
> https://github.com/clojure/clojure/blob/0b73494c3c855e54b1da591eeb687f24f608f346/test/clojure/test_helper.clj#L126
>
> One problem is, though, that you not only get reflection warnings for
> your own code but also for code in dependencies.  So you need to tweak
> that macro with another regex that matches only reflection warnings in
> your own files.  But then you should be able to do something like this:
>
>
> (ns myproject.test
>   :require [clojure.test :as test])
>
> (defmacro should-not-reflect ...)
>   
> (test/deftest no-reflection-at-all
>   (should-not-reflect
> (do
>   (require 'myproject.ns1 :reload)
>   (require 'myproject.ns2 :reload)
>   ...)))
>
>
> HTH,
> Tassilo
>
>

-- 
Phillip Lord,   Phone: +44 (0) 191 222 7827
Lecturer in Bioinformatics, Email: phillip.l...@newcastle.ac.uk
School of Computing Science,
http://homepages.cs.ncl.ac.uk/phillip.lord
Room 914 Claremont Tower,   skype: russet_apples
Newcastle University,   twitter: phillord
NE1 7RU 

-- 
-- 
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.


Re: error-on-reflection

2013-12-09 Thread John D. Hume
Are you aware of `lein check`? We have our some of our CI builds wired to
fail if that finds anything.
On Dec 9, 2013 4:12 AM, "Phillip Lord"  wrote:

>
> I know about *warn-on-reflection* but is there anyway that I can get an
> error-on-reflection instead?
>
> I've been type hinting my application (50% done and yes it goes faster
> now), and it's a bit painful. What I would really want is to have a unit
> test which fails if reflection is used.
>
> So far, my best idea is catching standard-out and parsing it for
> reflection warnings. Not ideal.
>
> Phil
>
> --
> --
> 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.
>

-- 
-- 
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.


Re: error-on-reflection

2013-12-09 Thread Tassilo Horn
phillip.l...@newcastle.ac.uk (Phillip Lord) writes:

> I know about *warn-on-reflection* but is there anyway that I can get
> an error-on-reflection instead?

I don't think so.

> I've been type hinting my application (50% done and yes it goes faster
> now), and it's a bit painful. What I would really want is to have a
> unit test which fails if reflection is used.
>
> So far, my best idea is catching standard-out and parsing it for
> reflection warnings. Not ideal.

clojure/test/clojure/test_helper.clj already contains some helper macros
for doing that, e.g., `should-not-reflect`:

https://github.com/clojure/clojure/blob/0b73494c3c855e54b1da591eeb687f24f608f346/test/clojure/test_helper.clj#L126

One problem is, though, that you not only get reflection warnings for
your own code but also for code in dependencies.  So you need to tweak
that macro with another regex that matches only reflection warnings in
your own files.  But then you should be able to do something like this:

--8<---cut here---start->8---
(ns myproject.test
  :require [clojure.test :as test])

(defmacro should-not-reflect ...)
  
(test/deftest no-reflection-at-all
  (should-not-reflect
(do
  (require 'myproject.ns1 :reload)
  (require 'myproject.ns2 :reload)
  ...)))
--8<---cut here---end--->8---

HTH,
Tassilo

-- 
-- 
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.


error-on-reflection

2013-12-09 Thread Phillip Lord

I know about *warn-on-reflection* but is there anyway that I can get an
error-on-reflection instead?

I've been type hinting my application (50% done and yes it goes faster
now), and it's a bit painful. What I would really want is to have a unit
test which fails if reflection is used. 

So far, my best idea is catching standard-out and parsing it for
reflection warnings. Not ideal.

Phil

-- 
-- 
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.