Setting *warn-on-reflection* such that multiple threads can see it

3 views
Skip to first unread message

Chris Jenkins

unread,
Nov 24, 2009, 12:38:32 PM11/24/09
to clo...@googlegroups.com
Hi,

Is it possible to set *warn-on-reflection* such that it can be seen by multiple threads? I can't use def to define *warn-on-reflection* because it is defined in another namespace. I can use set! to change the value of the binding for one thread but this is not seen by other threads:

(set! *warn-on-reflection* true)
(.start (Thread. #(println *warn-on-reflection*)))

...prints false

The reason that I would like to do this is that I'm writing a program that uses Swing and I'd like to see if reflection is used on callbacks that execute on the AWT event thread... ideally without having to figure out how to make Swing call my function that sets *warn-on-reflection* before it does anything else.

Cheers,

Chris

Christophe Grand

unread,
Nov 24, 2009, 2:04:15 PM11/24/09
to clo...@googlegroups.com
Hi,

*warn-on-reflection* is a compile-time flag, not a runtime flag so, unless you are using eval in the event thread, you don't need to care. Clojure outputs the warnings once: when you define the function.

hth,

Christophe

--
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.cgrand.net/ (en)

Chris Jenkins

unread,
Nov 24, 2009, 2:09:49 PM11/24/09
to clo...@googlegroups.com
That's great - now why didn't I realise that :-)

Thanks,

Chris




2009/11/24 Christophe Grand <chris...@cgrand.net>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply all
Reply to author
Forward
0 new messages