[ANN] Luke VanderHart's "Clojure Zippers" Conj video up
Hi everyone, We've just released the next Conj video, Luke VanderHart's talk on Clojure Zippers: http://clojure.blip.tv/file/4503162/ I've also just blogged over at clojure.com on what our video release plan is, along with links to videos released so far: http://clojure.com/blog/2010/12/27/conj-videos.html The source for all videos Clojure is still http://clojure.blip.tv/, and if you'd like to know the moment the next video is available, be sure to follow clojure_conj on Twitter: http://twitter.com/clojure_conj Thank you, and Happy Holidays, Alan and the Clojure/core team -- 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
Clojure Conj 2011?
Now that videos are being posted for the 2010 conj, I figured it might be worth asking if there has been any discussion about when/where the 2011 conj might happen? I had a schedule conflict last year (actually a double conflict) so I'd like to get this year's event on my calendar as early as possible so I don't miss it again :) -- Sean A Corfield -- (904) 302-SEAN Railo Technologies, Inc. -- http://getrailo.com/ An Architect's View -- http://corfield.org/ "If you're not annoying somebody, you're not really alive." -- Margaret Atwood -- 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
Re: Clojure Conj 2011?
Hi, On Mon, Dec 27, 2010 at 7:41 PM, Sean Corfield wrote: > Now that videos are being posted for the 2010 conj, I figured it might > be worth asking if there has been any discussion about when/where the > 2011 conj might happen? Conj 2011 will most likely be in either Raleigh or Durham, North Carolina, and probably will happen around the same time of year as the last Conj. We've reviewed all the feedback we've gotten, and are looking for a venue. Our hope is to announce the time and place as soon as possible. Sorry you couldn't make it to the last one, but looking forward to seeing you at the next one! Alan > > I had a schedule conflict last year (actually a double conflict) so > I'd like to get this year's event on my calendar as early as possible > so I don't miss it again :) > -- > Sean A Corfield -- (904) 302-SEAN > Railo Technologies, Inc. -- http://getrailo.com/ > An Architect's View -- http://corfield.org/ > > "If you're not annoying somebody, you're not really alive." > -- Margaret Atwood > > -- > 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 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
Re: Clojure Conj 2011?
On Mon, Dec 27, 2010 at 6:07 PM, Alan Dipert wrote: > Conj 2011 will most likely be in either Raleigh or Durham, North > Carolina, and probably will happen around the same time of year as the > last Conj. Good to know. I just hope it won't be the weekend of October 22-23 :( One of the events that conflicted in 2010 is on those dates in 2011. -- Sean A Corfield -- (904) 302-SEAN Railo Technologies, Inc. -- http://getrailo.com/ An Architect's View -- http://corfield.org/ "If you're not annoying somebody, you're not really alive." -- Margaret Atwood -- 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
Re: printf output from threads
On Dec 26, 11:42 pm, Alex Osborne wrote: > justinhj writes: > > I tried passing *out* to my thread function and then binding it to > > *out* in the thread, and this works but then makes the threads execute > > one at a time, and I'm presuming that is because my use of *out* in > > the binding block is blocking for the other threads which use it. > > That doesn't sound right: binding itself never blocks. Can you post > some example code where you see this behaviour? > > As I understand it binding conveyance should happen automatically in the > upcoming 1.3 release (for futures and agents) but in 1.2 you can use > bound-fn, or for better performance use binding explicitly as you > suggested. > > (future-call (bound-fn [] (println "log..."))) > > (send some-agent (bound-fn [x] (println "log...") (inc x))) This is the code I've written so far (defn sleeper-thread [out id t] "Sleep for time T ms" (binding [*out* out] (printf "%d sleeping for time %d\n" id t) (Thread/sleep t) (printf "%d slept\n" id))) (defn test-threads [n out] (dotimes [x n] (.start (Thread. (#(sleeper-thread %1 %2 %3) out x (+ 2000 (rand- int 5000))) And the output is 0 sleeping for time 5480 0 slept 1 sleeping for time 6739 1 slept 2 sleeping for time 5444 2 slept 3 sleeping for time 3087 3 slept 4 sleeping for time 6753 4 slept 5 sleeping for time 3489 5 slept 6 sleeping for time 5864 6 slept 7 sleeping for time 5523 7 slept 8 sleeping for time 5659 8 slept 9 sleeping for time 5052 9 slept -- 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
Re: printf output from threads
justinhj writes: > On Dec 26, 11:42 pm, Alex Osborne wrote: > (defn test-threads [n out] > (dotimes [x n] > (.start (Thread. (#(sleeper-thread %1 %2 %3) out x (+ 2000 (rand- > int 5000))) Ah. The problem is here. You're calling that lambda in the main thread and then passing the return value of sleeper-thread to (Thread.) (which doesn't make much sense). Try this: (defn test-threads [n out] (dotimes [x n] (.start (Thread. #(sleeper-thread out x (+ 2000 (rand-int 5000))) Or even: (defn test-threads [n out] (dotimes [x n] (future (sleeper-thread out x (+ 2000 (rand-int 5000)) Or forgetting about passing the out argument around: (defn test-threads [n] (dotimes [x n] (let [out *out*] (future (binding [*out* out] (sleeper-thread x (+ 2000 (rand-int 5000)) You could turn that into a macro: (defmacro future-with-out [& body] `(let [out# *out*] (future (binding [*out* out#] ~...@body))) And then use it like: (defn test-threads [n] (dotimes [x n] (future-with-out (sleeper-thread x (+ 2000 (rand-int 5000)) -- 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
Re: printf output from threads
Your problem is caused by one itty-bitty misplaced parenthesis that is hard to catch; In your code which creates threads, you do: (.start (Thread. (#(sleeper-thread %1 %2 %3) out x (+ 2000 (rand-int 5000))) #(sleeper-thread %1 %2 %3) is exactly the same as just sleeper-thread, so this boils down to (.start (Thread. (sleeper-thread out x (+ 2000 (rand-int 5000))) and now you can see that you are evaulating your sleeper-thread function before you actually create the thread. Thread wants Runnable object like a clojure function with no arguments, so either (.start (Thread. #(sleeper-thread out x (+ 2000 (rand-int 5000))) or (.start (Thread. (partial sleeper-thread out x (+ 2000 (rand-int 5000))) would work and do what you expect. Here's a modified version of your code with output: (ns mailing-list.print-from-threads) (defn sleeper-thread [out id t] "Sleep for time T ms" (binding [*out* out] (let [start (System/nanoTime)] (printf "%d sleeping for time %d\n" id t) (Thread/sleep t) (printf "%d slept for %d\n" id (int (/ (- (System/nanoTime) start) 1e6)) (defn test-threads-rlm [n out] (let [start (System/nanoTime)] (dotimes [x n] (.start (Thread. (partial sleeper-thread out x (+ 2000 (rand-int 5000)) (println "Total time is:" (int (/ (- (System/nanoTime) start) 1e6) (defn test-threads [n out] (let [start (System/nanoTime)] (dotimes [x n] (.start (Thread. (#(sleeper-thread %1 %2 %3) out x (+ 2000 (rand-int 5000)) (println "Total time is:" (int (/ (- (System/nanoTime) start) 1e6) mailing-list.print-from-threads> (test-threads-rlm 4 *out*) 0 sleeping for time 6783 1 sleeping for time 3716 2 sleeping for time 6890 Total time is: 2 3 sleeping for time 5582 1 slept for 3716 3 slept for 5582 0 slept for 6783 2 slept for 6890 nil mailing-list.print-from-threads> (test-threads 4 *out*) 0 sleeping for time 5875 0 slept for 5875 1 sleeping for time 3413 1 slept for 3413 2 sleeping for time 3709 2 slept for 3710 3 sleeping for time 5483 3 slept for 5484 Total time is: 18486 nil mailing-list.print-from-threads> However, I am vexed at how your original code works at all! look at this! --- ;;works (Thread. (#(sleeper-thread %1 %2 %3) *out* 2 (+ 2000 (rand-int 5000 (= nil (#(sleeper-thread %1 %2 %3) *out* 2 (+ 2000 (rand-int 5000 ;;true ;;doesn't work (Thread. nil) ;;works (Thread. ((fn [a b c] (sleeper-thread a b c)) *out* 2 (+ 2000 (rand-int 5000 ;;works (Thread. ((fn []))) How can you make a Thread with ((fn [])) when (= ((fn [])) nil) sincerely, --Robert McIntyre On Tue, Dec 28, 2010 at 1:45 AM, justinhj wrote: > On Dec 26, 11:42 pm, Alex Osborne wrote: >> justinhj writes: >> > I tried passing *out* to my thread function and then binding it to >> > *out* in the thread, and this works but then makes the threads execute >> > one at a time, and I'm presuming that is because my use of *out* in >> > the binding block is blocking for the other threads which use it. >> >> That doesn't sound right: binding itself never blocks. Can you post >> some example code where you see this behaviour? >> >> As I understand it binding conveyance should happen automatically in the >> upcoming 1.3 release (for futures and agents) but in 1.2 you can use >> bound-fn, or for better performance use binding explicitly as you >> suggested. >> >> (future-call (bound-fn [] (println "log..."))) >> >> (send some-agent (bound-fn [x] (println "log...") (inc x))) > > This is the code I've written so far > > (defn sleeper-thread [out id t] > "Sleep for time T ms" > (binding [*out* out] > (printf "%d sleeping for time %d\n" id t) > (Thread/sleep t) > (printf "%d slept\n" id))) > > (defn test-threads [n out] > (dotimes [x n] > (.start (Thread. (#(sleeper-thread %1 %2 %3) out x (+ 2000 (rand- > int 5000))) > > And the output is > > 0 sleeping for time 5480 > 0 slept > 1 sleeping for time 6739 > 1 slept > 2 sleeping for time 5444 > 2 slept > 3 sleeping for time 3087 > 3 slept > 4 sleeping for time 6753 > 4 slept > 5 sleeping for time 3489 > 5 slept > 6 sleeping for time 5864 > 6 slept > 7 sleeping for time 5523 > 7 slept > 8 sleeping for time 5659 > 8 slept > 9 sleeping for time 5052 > 9 slept > > -- > 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 post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your f
can members of a defrecord be type hinted?
Hello everybody, can members of a record be type hinted? will this enhance performance or improve storage efficiency? Sunil. -- 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
Re: printf output from threads
what the heck... mailing-list.print-from-threads> (Thread. ((constantly nil))) # mailing-list.print-from-threads> (Thread. ((fn []))) # mailing-list.print-from-threads> (Thread. ((fn [] nil))) # mailing-list.print-from-threads> (Thread. (let [this-is-nil ((fn [] nil))] this-is-nil)) # mailing-list.print-from-threads> (Thread. nil) ; Evaluation aborted. mailing-list.print-from-threads> (= nil (let [this-is-nil ((fn [] nil))] this-is-nil) ((fn [])) ((constantly nil))) true mailing-list.print-from-threads> all of these things are referentially transparent, so how is clojure differentiating between things that evaluate to nil and nil itself? sincerely, --Robert McIntyre On Tue, Dec 28, 2010 at 2:29 AM, Robert McIntyre wrote: > Your problem is caused by one itty-bitty misplaced parenthesis that is > hard to catch; In your code which creates threads, you do: > > (.start (Thread. (#(sleeper-thread %1 %2 %3) out x (+ 2000 (rand-int > 5000))) > > #(sleeper-thread %1 %2 %3) is exactly the same as just sleeper-thread, > so this boils down to > > (.start (Thread. (sleeper-thread out x (+ 2000 (rand-int 5000))) > > and now you can see that you are evaulating your sleeper-thread > function before you actually create the thread. > > Thread wants Runnable object like a clojure function with no > arguments, so either > > (.start (Thread. #(sleeper-thread out x (+ 2000 (rand-int 5000))) > > or > > (.start (Thread. (partial sleeper-thread out x (+ 2000 (rand-int 5000))) > > would work and do what you expect. Here's a modified version of your > code with output: > > > > > > (ns mailing-list.print-from-threads) > > (defn sleeper-thread [out id t] > "Sleep for time T ms" > (binding [*out* out] > (let [start (System/nanoTime)] > (printf "%d sleeping for time %d\n" id t) > (Thread/sleep t) > (printf "%d slept for %d\n" id (int (/ (- (System/nanoTime) > start) 1e6)) > > (defn test-threads-rlm [n out] > (let [start (System/nanoTime)] > (dotimes [x n] > (.start (Thread. > (partial sleeper-thread out x (+ 2000 (rand-int > 5000)) > (println "Total time is:" (int (/ (- (System/nanoTime) start) > 1e6) > > > (defn test-threads [n out] > (let [start (System/nanoTime)] > (dotimes [x n] > (.start (Thread. > (#(sleeper-thread %1 %2 %3) out x (+ 2000 (rand-int > 5000)) > (println "Total time is:" (int (/ (- (System/nanoTime) start) > 1e6) > > > > mailing-list.print-from-threads> (test-threads-rlm 4 *out*) > 0 sleeping for time 6783 > 1 sleeping for time 3716 > 2 sleeping for time 6890 > Total time is: 2 > 3 sleeping for time 5582 > 1 slept for 3716 > 3 slept for 5582 > 0 slept for 6783 > 2 slept for 6890 > nil > mailing-list.print-from-threads> (test-threads 4 *out*) > 0 sleeping for time 5875 > 0 slept for 5875 > 1 sleeping for time 3413 > 1 slept for 3413 > 2 sleeping for time 3709 > 2 slept for 3710 > 3 sleeping for time 5483 > 3 slept for 5484 > Total time is: 18486 > nil > mailing-list.print-from-threads> > > > However, I am vexed at how your original code works at all! > > look at this! --- > > > ;;works > (Thread. (#(sleeper-thread %1 %2 %3) *out* 2 (+ 2000 (rand-int > 5000 > (= nil (#(sleeper-thread %1 %2 %3) *out* 2 (+ 2000 (rand-int 5000 > ;;true > > > ;;doesn't work > (Thread. nil) > > ;;works > (Thread. ((fn [a b c] (sleeper-thread a b c)) *out* 2 (+ 2000 > (rand-int 5000 > > ;;works > (Thread. ((fn []))) > > > How can you make a Thread with ((fn [])) > when (= ((fn [])) nil) > > > sincerely, > > --Robert McIntyre > > > > > On Tue, Dec 28, 2010 at 1:45 AM, justinhj wrote: >> On Dec 26, 11:42 pm, Alex Osborne wrote: >>> justinhj writes: >>> > I tried passing *out* to my thread function and then binding it to >>> > *out* in the thread, and this works but then makes the threads execute >>> > one at a time, and I'm presuming that is because my use of *out* in >>> > the binding block is blocking for the other threads which use it. >>> >>> That doesn't sound right: binding itself never blocks. Can you post >>> some example code where you see this behaviour? >>> >>> As I understand it binding conveyance should happen automatically in the >>> upcoming 1.3 release (for futures and agents) but in 1.2 you can use >>> bound-fn, or for better performance use binding explicitly as you >>> suggested. >>> >>> (future-call (bound-fn [] (println "log..."))) >>> >>> (send some-agent (bound-fn [x] (println "log...") (inc x))) >> >> This is the code I've written so far >> >> (defn sleeper-thread [out id t] >> "Sleep for time T ms" >> (binding [*out* out] >> (printf "%d sleeping for time %d\n" id t) >> (Thread/sleep t) >> (printf "%d slept\n" id))) >> >> (defn test-threads [n out] >> (dotimes [x n] >> (.start (Thread. (#(sleeper-thread %1 %2 %3) out x (+ 2000 (rand- >> int 5000))) >> >> And the output is >> >> 0 sleeping for time 5480 >> 0 slept >> 1 sleeping for time 6739 >> 1 slep
Re: can members of a defrecord be type hinted?
with my preliminary examination it seems like it does enhance storage efficiency and improve runtime performance.. How would still love to hear what you all have to say On Tue, Dec 28, 2010 at 1:02 PM, Sunil S Nandihalli < sunil.nandiha...@gmail.com> wrote: > Hello everybody, > can members of a record be type hinted? will this enhance performance or > improve storage efficiency? > Sunil. > -- 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