Re: Using 'future' ?

2009-10-19 Thread Meikel Brandmeyer
Hi, Am 19.10.2009 um 06:39 schrieb Gorsal: > So now that the future is working, I'm attempting to print from an > actual java thread. Like this > > (defmacro with-thread [nm & body] > `(let [thread# (Thread. #(fn [] (do ~...@body)))] > ~@(if nm `((.setName thread# ~nm))) > (.start thread

Re: Using 'future' ?

2009-10-18 Thread John Harrop
On Mon, Oct 19, 2009 at 12:39 AM, Gorsal wrote: > > So now that the future is working, I'm attempting to print from an > actual java thread. Like this > > (defmacro with-thread [nm & body] > `(let [thread# (Thread. #(fn [] (do ~...@body)))] > ~@(if nm `((.setName thread# ~nm))) > (.start

Re: Using 'future' ?

2009-10-18 Thread Gorsal
Thanks. I think now that i recall i have made that mistake before. I must differentiate - fn and #()! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googl

Re: Using 'future' ?

2009-10-18 Thread Adrian Cuthbertson
Just an addendum to my last post - without the .start you can test it better; (defmacro with-thread [nm & body] `(let [thread# (Thread. (fn [] (do ~...@body)))] (if ~nm (.setName thread# ~nm)) ;(.start thread#) thread#)) (def th (with-thread "foo" (println "Hasdfasdfasdfasdfasdfasdf

Re: Using 'future' ?

2009-10-18 Thread Adrian Cuthbertson
The following seems to do it; (defmacro with-thread [nm & body] `(let [thread# (Thread. (fn [] (do ~...@body)))] (if ~nm (.setName thread# ~nm)) (.start thread#) thread#)) (with-thread "foo" (println "HasdfasdfasdfasdfasdfasdfasdfasdfI")) # user=> HasdfasdfasdfasdfasdfasdfasdfasdfI

Re: Using 'future' ?

2009-10-18 Thread Timothy Pratley
On Oct 19, 3:39 pm, Gorsal wrote: > Except no output! Eeek!!! What am i doing wrong? Looks like #(fn ... is meant to be #(do ~...@body) #(fn declares a function which creates a function, so your thread is returning a function instead of executing it. user=> (macroexpand-1 '(with-thread nil (pr

Re: Using 'future' ?

2009-10-18 Thread John Harrop
On Sun, Oct 18, 2009 at 10:22 PM, Gorsal wrote: > > Hey, is there any way to separate the out view from the repl view so i > don't have to switch back and forth? > In Enclojure? Unfortunately, apparently not. It's possible to undock the REPL and make it a free-floating window, but all three of th

Re: Using 'future' ?

2009-10-18 Thread Gorsal
So now that the future is working, I'm attempting to print from an actual java thread. Like this (defmacro with-thread [nm & body] `(let [thread# (Thread. #(fn [] (do ~...@body)))] ~@(if nm `((.setName thread# ~nm))) (.start thread#) thread#)) (with-thread nil (println "Hasdfasd

Re: Using 'future' ?

2009-10-18 Thread Gorsal
Hey, is there any way to separate the out view from the repl view so i don't have to switch back and forth? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@

Re: Using 'future' ?

2009-10-18 Thread Gorsal
Thanks, this works. --~--~-~--~~~---~--~~ 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

Re: Using 'future' ?

2009-10-18 Thread Timothy Pratley
> Most likely, though, it's an unfortunate effect of how futures print > themselves: > > user=> (future (* 3 4)) > # I agree - this is the cause, if you really wanted to do this at the REPL maybe you can get around it like this: user=> (do (future (* 3 4)) nil) nil --~--~-~--~~---

Re: Using 'future' ?

2009-10-18 Thread John Harrop
On Sun, Oct 18, 2009 at 5:59 PM, Gorsal wrote: > > I'm attempting to use the function future to start something in > another thread. However, in the netbeans enclojure plugin, when i type > it into the repl, it becomes non-responsive. Is this just a bug in the > enclojure plugin or would this be

Using 'future' ?

2009-10-18 Thread Gorsal
I'm attempting to use the function future to start something in another thread. However, in the netbeans enclojure plugin, when i type it into the repl, it becomes non-responsive. Is this just a bug in the enclojure plugin or would this be normal? (future (let [input-stream (:input-stream *li