Re: Proxy Bug?

2008-10-29 Thread mb
Hi, On 30 Okt., 00:31, ntupel <[EMAIL PROTECTED]> wrote: > Consider the following code which attempts to redefine clojure/*out*: > (def output-stream > (let [buffer (new java.io.ByteArrayOutputStream)] > (proxy [java.io.OutputStream] [] > (flush [] > (.append output (.toString

Re: Ants and agents

2008-10-29 Thread Tom Davies
On Oct 30, 12:14 pm, "Jim Menard" <[EMAIL PROTECTED]> wrote: > I was looking at the same code today. My question is slightly > different. In the code > > (defn evaporation [x] >   (when running >     (send-off *agent* #'evaporation)) >   (evaporate) >   (. Thread (sleep evap-sleep-ms)) >   nil)

Re: Ants and agents

2008-10-29 Thread Stuart Halloway
Hi Jim, send-off is never immediate. It schedules a function for execution later. The call to send-off queues execution of the next evaporation, and the code continues on. Agents cannot do more than one thing at once, so the queued evaporation cannot possibly happen while this evaporation

Re: Ants and agents

2008-10-29 Thread Jim Menard
I was looking at the same code today. My question is slightly different. In the code (defn evaporation [x] (when running (send-off *agent* #'evaporation)) (evaporate) (. Thread (sleep evap-sleep-ms)) nil) it looks like the next request (when running (send-off...)) is sent immediately

Proxy Bug?

2008-10-29 Thread ntupel
Consider the following code which attempts to redefine clojure/*out*: (ns test (:refer-clojure)) (def output System/out) (def output-stream (let [buffer (new java.io.ByteArrayOutputStream)] (proxy [java.io.OutputStream] [] (flush [] (.append output (.toString buffer "UTF-

Re: ILC 2009

2008-10-29 Thread Rich Hickey
On Oct 29, 4:50 pm, "Matthew D. Swank" <[EMAIL PROTECTED]> wrote: > Are people going to ILC this spring? Rich, do you have any plans to do > anything Clojure related there? > I've been (informally) invited, so yes, I'm planning to speak. I'd like also to possibly do some more extensive tutorial

Re: Not Your Daddy's Namespaces

2008-10-29 Thread Bill Clementson
On Wed, Oct 29, 2008 at 1:20 PM, Rich Hickey <[EMAIL PROTECTED]> wrote: > > > > On Oct 29, 2:03 pm, "Bill Clementson" <[EMAIL PROTECTED]> wrote: >> Hi Stuart, >> >> Thanks, that's good to know - I didn't realize the ns macro did that! >> I just had a look at the docstring for ns: >> >> "Sets *ns*

ILC 2009

2008-10-29 Thread Matthew D. Swank
Are people going to ILC this spring? Rich, do you have any plans to do anything Clojure related there? Matt --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojur

Re: Debugging with JSwat

2008-10-29 Thread Craig Andera
As a follow-on to this, it turns out that debugging works *only* when I pull the files in via require; neither slime-load-file nor slime-eval-buffer nor load-file result in breakpoints getting hit. On Fri, Oct 24, 2008 at 1:27 PM, Craig Andera <[EMAIL PROTECTED]> wrote: >>> It's very likely/nearl

Re: Not Your Daddy's Namespaces

2008-10-29 Thread Rich Hickey
On Oct 29, 2:03 pm, "Bill Clementson" <[EMAIL PROTECTED]> wrote: > Hi Stuart, > > Thanks, that's good to know - I didn't realize the ns macro did that! > I just had a look at the docstring for ns: > > "Sets *ns* to the namespace named by name (unevaluated), creating it > if needed. references

Re: Currying for Clojure

2008-10-29 Thread André Thieme
On 26 Okt., 06:23, "Matthew D. Swank" <[EMAIL PROTECTED]> wrote: > I am dubious of the curry proposal, Hi Matt! Could you please be more specific about what makes you dubious? I understand that the #(..) reader macro can’t be used, but this won’t keep us from having some other instead. It could

Re: Newbie question: testing if an object is a Struct of a certain kind

2008-10-29 Thread samppi
Okay, I understand. Thanks for the answer. On Oct 29, 12:01 pm, "Graham Fawcett" <[EMAIL PROTECTED]> wrote: > On Wed, Oct 29, 2008 at 2:29 PM, samppi <[EMAIL PROTECTED]> wrote: > > > Is there a way to test an object if it's a certain kind of struct? > > >  (defstruct person :name :age) > >  (def

Re: Newbie question: testing if an object is a Struct of a certain kind

2008-10-29 Thread Graham Fawcett
On Wed, Oct 29, 2008 at 2:29 PM, samppi <[EMAIL PROTECTED]> wrote: > > Is there a way to test an object if it's a certain kind of struct? > > (defstruct person :name :age) > (def president (struct person "Sam" 30)) > (struct? person president) ; true Hi, Defstruct doesn't define a new type in

Re: IntelliJ Plugin

2008-10-29 Thread Peter Wolf
Actually, I realize now that I am going to use EMACS. The thing that makes IntelliJ really great is the automatic refactoring of Java code, and the management of a g-zillion Java files. It really has no big advantages for Clojure. For hacking LISP, EMACS is still the king! Tom Emerson wrote:

Newbie question: testing if an object is a Struct of a certain kind

2008-10-29 Thread samppi
Is there a way to test an object if it's a certain kind of struct? (defstruct person :name :age) (def president (struct person "Sam" 30)) (struct? person president) ; true Thanks in advance. --~--~-~--~~~---~--~~ You received this message because you are s

Re: Not Your Daddy's Namespaces

2008-10-29 Thread Bill Clementson
Hi Stuart, Thanks, that's good to know - I didn't realize the ns macro did that! I just had a look at the docstring for ns: "Sets *ns* to the namespace named by name (unevaluated), creating it if needed. references can be zero or more of: (:refer-clojure ...) (:require ...) (:use ...) (:imp

Re: string interpolation

2008-10-29 Thread Graham Fawcett
On Wed, Oct 29, 2008 at 1:27 PM, Kyle R. Burton <[EMAIL PROTECTED]> wrote: > >> Thanks for the macro. =) >> The str function is really a good replacement for interpolation. > > Yes, thank you for the macro. I anticipate using this approach (I'm > accustomed to it from Ruby, Perl and JScheme), but

Re: string interpolation

2008-10-29 Thread Kyle R. Burton
> Thanks for the macro. =) > The str function is really a good replacement for interpolation. Yes, thank you for the macro. I anticipate using this approach (I'm accustomed to it from Ruby, Perl and JScheme), but wanted to support a way of stopping the parser (by backslashing the opening brace:

Re: Documentation string in metadata?

2008-10-29 Thread Stuart Halloway
Axel, The second function definition doesn't have a documentation string, it has a string form in its body. Valid behavior, but potentially confusing. Stuart > the metadata for the second function definition > doesn't contain the documentation string. I was > wondering if this is valid beha

Documentation string in metadata?

2008-10-29 Thread Axel Schlueter
the metadata for the second function definition doesn't contain the documentation string. I was wondering if this is valid behaviour or a bug? user> (defn foobar "foobar" [] ()) user> (:doc (meta #'foobar)) "foobar" user> (defn foobar [] "foobar" ()) user> (:doc (meta #'foobar)) nil Regards,

Re: Not Your Daddy's Namespaces

2008-10-29 Thread Stuart Halloway
Hi Bill, Good stuff. You might also mention that when you actually switch to a namespace using the ns macro, clojure gets referred, giving you a bunch more stuff: (create-ns 'test) #=(find-ns test) user=> (count (ns-map 'test)) 96 user=> (ns test) nil test=> (ns user) nil user=> (count (ns

Not Your Daddy's Namespaces

2008-10-29 Thread bc
Hi all, I've posted a new article on my blog about Clojure Namespaces: http://bc.tech.coop/blog/081029.html I would appreciate any comments/criticisms or additional insights. Thanks, Bill --~--~-~--~~~---~--~~ You received this message because you are subscribed

Re: Ants and agents

2008-10-29 Thread Rich Hickey
And 2 is yes, just to stop them at the repl by flipping a flag. Was especially useful when first coding it up. Rich On Oct 29, 11:20 am, Stuart Halloway <[EMAIL PROTECTED]> wrote: > Hi Konrad, > > I can answer 1 and 3: > > (1) *agent* is set thread locally whenever a thread is an agent > action.

Re: IntelliJ Plugin

2008-10-29 Thread Tom Emerson
On Mon, Oct 27, 2008 at 11:00 AM, opus111 <[EMAIL PROTECTED]> wrote: > Is anyone working on a Clojure plugin for IntelliJ? Not that I've seen, but there is Enclojure which is built on top of NetBeans. -tree -- Tom Emerson [EMAIL PROTECTED] http://www.dreamersrealm.n

Re: Ants and agents

2008-10-29 Thread Stuart Halloway
Hi Konrad, I can answer 1 and 3: (1) *agent* is set thread locally whenever a thread is an agent action. It's all in the Java code, grep for AGENT (3) send uses a thread pool that you should not assume you control, so blocking for e.g. I/O would be bad behavior and could hurt other agents

Ants and agents

2008-10-29 Thread [EMAIL PROTECTED]
I am trying to understand Rich's ant colony demo. It is pretty clear overall, except for one aspect: the use of (when running (send-off *agent* ...)) in all the functions executed by the agents, where ... stands for the function itself. My guess is that this simply sends another requ

Re: idiomatic Clojure for agents?

2008-10-29 Thread stephan
Hi Stuart, the code didn't run for me. On Oct 28, 3:06 am, Stuart Halloway <[EMAIL PROTECTED]> wrote: > ; guess pi by running Monte Carlo simulation count times > ; spread across n agents > (defn guess-pi-agent [n count] >(let [count (quot count n) > agents (for [_ (range n)] (agent

Re: Numbers API has no abs function

2008-10-29 Thread Paul Drummond
On Oct 29, 1:46 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > How about this: > >(defn abs [x] > (if (< x 0) (- x) x)) I will use that - I should have considered making my own version rather than messing around with BigDecimal.abs(). Thanks! --~--~-~--~~---

Re: Reader + Macros on untrusted S Expressions: Security considerations?

2008-10-29 Thread Tom Hickey
On Oct 29, 10:10 am, Chouser <[EMAIL PROTECTED]> wrote: > Is there something wrong with JSON I'm not seeing? Not at all. I use JSON myself and am totally fine with keeping it that way. I just thought the idea of reading Clojure data on the JS side was interesting/fun. --~--~-~--~~---

Re: Using a Java Debugger with Clojure

2008-10-29 Thread Luc Prefontaine
Pretty simple: ;; Load Spring stuff only if not already done (let [v (def *context*)] (when-not (. v isBound) (. v bindRoot (new ContextLoader "higiebusRouting.xml")) (. *context* load)) ) (def producer (. com.softaddicts.products.higiebus.core.BeanLoader getBean "jmsProducer")) ... (jms/send

Re: string interpolation

2008-10-29 Thread islon
Thanks for the macro. =) The str function is really a good replacement for interpolation. On Oct 28, 8:29 pm, "Graham Fawcett" <[EMAIL PROTECTED]> wrote: > On Tue, Oct 28, 2008 at 7:27 PM, Graham Fawcett > > <[EMAIL PROTECTED]> wrote: > > But for fun, here's an (i ...) macro, that will give you $

Re: Reader + Macros on untrusted S Expressions: Security considerations?

2008-10-29 Thread Chouser
On Wed, Oct 29, 2008 at 9:53 AM, Tom Hickey <[EMAIL PROTECTED]> wrote: > > Chouser, does ClojureScript not have something like this in order to > do read? It doesn't. ClojureScript currently uses the standard Clojure reader and parts of the compiler. This means, for example, that you can't have

Re: Using a Java Debugger with Clojure

2008-10-29 Thread Stuart Halloway
Hi Luc, Do you have any special sauce for Spring/Clojure integration that the community might be interested in? Or is it just so easy that there is nothing to say? :-) Stuart > Debugging presently with JSwat and it works fine. We have extensive > logging (javalog) and use some trace macro

Re: Reader + Macros on untrusted S Expressions: Security considerations?

2008-10-29 Thread Tom Hickey
On Oct 22, 9:41 am, Randall R Schulz <[EMAIL PROTECTED]> wrote: > On Wednesday 22 October 2008 06:27, .Bill Smith wrote: > > > Would you have S-expressions going from the server back to the client > > as well? > > If that client is a Web browser, then presumably it would require an > S-Expression

Re: Using a Java Debugger with Clojure

2008-10-29 Thread Luc Prefontaine
Debugging presently with JSwat and it works fine. We have extensive logging (javalog) and use some trace macros from time to time. Of course you have to get acquainted with the internal Clojure representation as shown by the debugger but that's not a big learning curve. Presently we use a mix of

Re: Numbers API has no abs function

2008-10-29 Thread [EMAIL PROTECTED]
On Oct 29, 2:20 pm, Paul Drummond <[EMAIL PROTECTED]> wrote: > Is there reason why abs is not part of the Numbers interface? I don't know, but... > Would be nice to be able to use: > > (abs -1.0) > 1 > (abs 1.0M) > 1M How about this: (defn abs [x] (if (< x 0) (- x) x)) This does wha

Numbers API has no abs function

2008-10-29 Thread Paul Drummond
Is there reason why abs is not part of the Numbers interface? Currently I need to differentiate between binary decimals and BigDecimals: (. java.lang.Math (abs -1)) 1 (. -1M (abs)) 1M And if I accidentally use BigDecimal in the wrong place I get an NPE: (. java.lang.Math (abs -1M)) java.lang.N

Re: idiomatic Clojure for agents?

2008-10-29 Thread Christian Vest Hansen
I'm not sure how relevant this is (I'm not familiar with Monte Carlo algorithms), but I needed a fast and thread-safe PRNG for some other project and ended up with this: http://github.com/karmazilla/nanopool/tree/master/src/main/java/net/nanopool/CheapRandom.java It's only a medium-quality PRNG a

International Lisp Conference 2009

2008-10-29 Thread Rich Hickey
CALL FOR SUBMISSIONS INTERNATIONAL LISP CONFERENCE 2009 Lisp: The Next 50 Years http://www.international-lisp-conference.org Massachusetts Institute of Technology Cambridge, Massachusetts, USA March 22-25, 2009