Re: question regarding agents

2009-09-23 Thread Roger Gilliar
Thanks for the answer. > Wrapping a mutable thing like an output stream in an agent seems > dubious to me. It was intended to use an agent here since I need to control the access to the write object. But what I forgot was ' the validator succeeds or if no validator was given, the return va

Re: Catching from Eval

2009-09-23 Thread Phil Hagelberg
John Harrop writes: > The exception is being transformed. Eval and just about anything using > closures -- just about any delayed evaluation, in other words -- wraps > exceptions in RuntimeException for some reason. Even if they already were > RuntimeExceptions (and InterruptedException isn't).

Re: clojure-test-mode overlays

2009-09-23 Thread Phil Hagelberg
Rick Moynihan writes: > Ahh, great! I have it working now... I was using clojure.test with > clojure 1.0 rather than test-is from contrib. My understanding was > that clojure.contrib.test-is was deprecated when test-is moved from > contrib into core. > > Does anyone know if this is the case?

Re: Catching from Eval

2009-09-23 Thread John Harrop
On Wed, Sep 23, 2009 at 6:42 PM, Phil Hagelberg wrote: > What's going on here? The exception is being transformed. Eval and just about anything using closures -- just about any delayed evaluation, in other words -- wraps exceptions in RuntimeException for some reason. Even if they already were

Re: Getting REPL transcript

2009-09-23 Thread songoku
> Vimclojure and emacs (on any operating system) will have at least the > ability to copy from the REPL's history and paste elsewhere in the editor, > but maybe not any nice way to export it to something else, like the mail > client used to post to this list. With emacs you can simply safe the buf

Bug in count for hash-maps with nil values

2009-09-23 Thread Jason Wolfe
On the most recent git revision of Clojure (branch master, commit 64323d8c6ad4962ac780d4d904b69a891ab312f8), user=> (count {1 nil 2 nil 3 nil 4 nil 5 nil 6 nil 7 nil 8 nil}) 8 user=> (count {1 nil 2 nil 3 nil 4 nil 5 nil 6 nil 7 nil 8 nil 9 nil}) 0 user=> (count {1 nil 2 nil 3 nil 4 nil 5 nil 6 n

Re: Q: is there a better way to do this

2009-09-23 Thread Timothy Pratley
Ok so there are two use cases: 1) testing constraint 2) referencing a snapshot And two operations A) @ B) ensure 1A is incorrect 1B is correct 2A is correct and concurrent 2B is correct but not concurrent "More concurrency" is the default. This increases the chance of incorrectness due to progr

Catching from Eval

2009-09-23 Thread Phil Hagelberg
I'm rather confused by the different behaviour I'm getting from these two similar-looking pieces of code. What's going on here? ;; works: (try (throw (InterruptedException.)) (catch InterruptedException _)) ;; exception is not caught: (try (eval '(throw (InterruptedException.))) (cat

Re: question regarding agents

2009-09-23 Thread John Harrop
On Wed, Sep 23, 2009 at 4:18 PM, Roger Gilliar wrote: > I have the following code: > > (defn handle-client [in out] >(binding [ >*in* (reader in) >] >(with-connection db >(let [outstream (agent (writer out))] >

Re: Architecting a large multi-threaded process

2009-09-23 Thread Roger Gilliar
> What I want is some way to schedule tasks to be executed by some set > of worker threads, and then be able to control the number of worker > threads on a server. What I'm interested in is other people's > opinions on how I should architect this app. Thi

Re: Architecting a large multi-threaded process

2009-09-23 Thread pmf
You might want to look into the stuff from JSR166 (scheduled for Java 7, but already available as a library for Java 6), which has advanced, built-in workload-balancing which is vastly easier than trying to do this with the raw, naive j.u.c.Executors-package (and Clojure's agents, which are backed

question regarding agents

2009-09-23 Thread Roger Gilliar
I have the following code: (defn handle-client [in out] (binding [ *in* (reader in) ] (with-connection db (let [outstream (agent (writer out))] (loop []

Architecting a large multi-threaded process

2009-09-23 Thread Brian Hurt
So, I'm working on a medium-largish server application in Clojure (medium amounts of code- currently >10KLOC and growing quickly, two people working on it now and hopefully more in the future. This isn't brag-worthy size, but it's large enough to start causing problems). Specifically, there will

Re: Getting REPL transcript

2009-09-23 Thread John Harrop
On Wed, Sep 23, 2009 at 1:05 PM, Fogus wrote: > If you're running it with JLine, then the transcript is usually stored > in ~/.jline-clojure.lang.Repl.history Actually, that suggests a more general point: that we can have programmatic access to the REPL's backlog if we modify the REPL process's

Re: Getting REPL transcript

2009-09-23 Thread John Harrop
On Wed, Sep 23, 2009 at 12:40 PM, Michael Wood wrote: > 2009/9/23 Phil Hagelberg : > > > > Emeka writes: > > > >> I would like to have a transcript of Repl. Could someone help me out > here? > > > > Sure; run it in GNU Screen with logging turned on. > > > > $ screen -l > > $ rlwrap java -cp cl

Re: trouble running clojure.test

2009-09-23 Thread John Harrop
On Wed, Sep 23, 2009 at 12:29 PM, MarkSwanson wrote: > Environment: vimclojure-2.1.2. clojure from git as of a few days ago. > > Running the tests in a plain REPL from the command line worked > perfectly! > -=* THANKS GUYS !!! *=- > > I wasn't expecting this at all. I thought the REPL in vimclojur

test.clj / test/tap.clj error

2009-09-23 Thread MarkSwanson
Hello, I'm trying to use tst/tap.clj but the tap output does not contain the 'not ok' line. I think this is a bug in tap.clj. Here is the small test: (ns tc (:use [clojure.test])) (deftest addition (is (= 4 (+ 2 2))) (is (= 8 (+ 3 4 >(use 'clojure.test) >(use 'clojure.t

Re: Namespace/class visibility in eval

2009-09-23 Thread John Harrop
On Wed, Sep 23, 2009 at 8:50 AM, Philipp Meier wrote: > On 23 Sep., 03:26, John Harrop wrote: > > But, this looks like a gaping security hole. You're taking an HTTP POST > > request body and eval'ing it. Someone will, sooner or later, try typing > > "(delete all the secret files)" into the web f

Re: where is the contrib?

2009-09-23 Thread 冯越
It's great. Thanks a lot! --~--~-~--~~~---~--~~ 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 patien

Re: Q: is there a better way to do this

2009-09-23 Thread Roger Gilliar
> And even then, ensure is often not needed and overkill. Make sure you > have a real business requirement that the predicate remain true (or > value fixed) on transaction completion. We need to move to a world in -- It seems that my problem falls exactly in this category. Ensuring *

Re: Getting REPL transcript

2009-09-23 Thread Fogus
If you're running it with JLine, then the transcript is usually stored in ~/.jline-clojure.lang.Repl.history --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to cloju

Re: Getting REPL transcript

2009-09-23 Thread Emeka
Mic, Or use "script" . I don't think I understood clearly what you are referring to. Regards, Emeka On Wed, Sep 23, 2009 at 4:40 PM, Michael Wood wrote: > > 2009/9/23 Phil Hagelberg : > > > > Emeka writes: > > > >> I would like to have a transcript of Repl. Could someone help me out > here? >

Re: Getting REPL transcript

2009-09-23 Thread Michael Wood
2009/9/23 Phil Hagelberg : > > Emeka writes: > >> I would like to have a transcript of Repl. Could someone help me out here? > > Sure; run it in GNU Screen with logging turned on. > >  $ screen -l >  $ rlwrap java -cp clojure.jar clojure.main >  => (do some stuff) > > It will get written to scree

Re: Getting REPL transcript

2009-09-23 Thread Phil Hagelberg
Emeka writes: > I would like to have a transcript of Repl. Could someone help me out here? Sure; run it in GNU Screen with logging turned on. $ screen -l $ rlwrap java -cp clojure.jar clojure.main => (do some stuff) It will get written to screenlog.0. -Phil --~--~-~--~~---

Re: trouble running clojure.test

2009-09-23 Thread MarkSwanson
Environment: vimclojure-2.1.2. clojure from git as of a few days ago. Running the tests in a plain REPL from the command line worked perfectly! -=* THANKS GUYS !!! *=- I wasn't expecting this at all. I thought the REPL in vimclojure actually supported stdout because this works: > (def a "abc") #

Getting REPL transcript

2009-09-23 Thread Emeka
Hello All, I would like to have a transcript of Repl. Could someone help me out here? Regards, Emeka --~--~-~--~~~---~--~~ 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: Q: is there a better way to do this

2009-09-23 Thread Rich Hickey
On Wed, Sep 23, 2009 at 10:17 AM, Christophe Grand wrote: > > > On Wed, Sep 23, 2009 at 7:14 AM, Timothy Pratley > wrote: >> >> When it useful to be able to deref inside a dosync without ensuring? > > > In a read-only transaction. > > >> >> Ensure seems like a more safe default of what I'd expec

Please apply build patch

2009-09-23 Thread Howard Lewis Ship
I submitted this simple patch about a month ago: https://www.assembla.com/spaces/clojure-contrib/tickets/22-clojure-contrib-str-utils2-is-not-AOT-compiled As it turns out, this patch is more important than I first thought ... other necessary classes are not being AOT compiled as well. Currently,

Re: Q: is there a better way to do this

2009-09-23 Thread Christophe Grand
On Wed, Sep 23, 2009 at 7:14 AM, Timothy Pratley wrote: > When it useful to be able to deref inside a dosync without ensuring? > In a read-only transaction. > Ensure seems like a more safe default of what I'd expect from a > transaction. So why not make deref automatically ensure within a > d

Re: Q: is there a better way to do this

2009-09-23 Thread Dave Jack
On Sep 23, 9:23 am, Dave Jack wrote: > Maybe @ should expand to ensure rather > than deref inside a transaction, instead? Should've thought about this more. How is the reader supposed to know that this code is called in a transaction? And it would leak if you deref'd inside a function called a

Re: New Release for Enclojure plugin - 2009-09-22

2009-09-23 Thread Eric Thorsen
I updated the plugin on the Netbeans plugin portal and have submitted it for verification. I believe once it has passed verification it will show up in the catalog. Thanks! Eric On Sep 22, 9:21 pm, Wilson MacGyver wrote: > any chance the enclojure plugin can be made available to download > fro

Re: trouble running clojure.test

2009-09-23 Thread Stuart Sierra
On Sep 23, 2:51 am, MarkSwanson wrote: > I'm having trouble unit testing clojure code. To be sure I'm just > testing clojure.test, I'm trying to test clojure.contrib.json.read. > > I'm sure I've missed it. test.clj contains defmethod report ... that > has the FAIL println in it. I do not know why

Re: Q: is there a better way to do this

2009-09-23 Thread Dave Jack
> When it useful to be able to deref inside a dosync without ensuring? When you deref and alter/set the same ref, the ref is protected from modification as well. I couldn't think of an example of what I think you had in mind, something that requires a transaction but is tolerant of modification o

Re: where is the contrib?

2009-09-23 Thread Stuart Sierra
Clojure-contrib is available on Github: http://github.com/richhickey/clojure-contrib/ -SS On Sep 23, 5:14 am, ELaN wrote: > I run a clj script file and get a FileNotFoundException. > The message is "Could not locate clojure/contrib/ > import_static__init.class or clojure/contrib/import_static.cl

Re: "If you wish to have a version for off-line use...

2009-09-23 Thread Mark Volkmann
It looks like that PDF is a little out of date. It doesn't include all the pages accessible from the left nav. at http://clojure.org. On Tue, Sep 22, 2009 at 7:51 PM, Julian wrote: > > Did you mean this? > http://clojure.googlegroups.com/web/manual.pdf > > On Sep 20, 4:59 am, cej38 wrote: >> I

Re: Namespace/class visibility in eval

2009-09-23 Thread Philipp Meier
On 23 Sep., 03:26, John Harrop wrote: > On Tue, Sep 22, 2009 at 6:46 PM, Eric Tschetter wrote: > But, this looks like a gaping security hole. You're taking an HTTP POST > request body and eval'ing it. Someone will, sooner or later, try typing > "(delete all the secret files)" into the web form

Re: How does (apply map + '((1 2) (2 3) (3 4))) work?

2009-09-23 Thread simon
That's good. Thanks. -Simon On Aug 19, 8:03 am, CuppoJava wrote: > (apply map + '((1 2) (2 3) (3 4))) > > is synonymous to: > > (map + [1 2] [2 3] [3 4]) > > So you get > > ( (1+2+3)  (2+3+4) )  = (6 9) > > Hope that helps >   -Patrick --~--~-~--~~~---~--~~ You

where is the contrib?

2009-09-23 Thread ELaN
I run a clj script file and get a FileNotFoundException. The message is "Could not locate clojure/contrib/ import_static__init.class or clojure/contrib/import_static.clj on classpath". But I didn't find any file or dir like contrib in the clojure files. If anyone have any solution,please share it

Re: Namespace/class visibility in eval

2009-09-23 Thread Rick Moynihan
> On Tue, Sep 22, 2009 at 6:46 PM, Eric Tschetter wrote: > But, this looks like a gaping security hole. You're taking an HTTP POST > request body and eval'ing it. Someone will, sooner or later, try typing > "(delete all the secret files)" into the web form and clicking Send. Or > worse, something

Re: "If you wish to have a version for off-line use...

2009-09-23 Thread Kei Suzuki
Long time ago I posted a message with a Clojure program that does what you are looking for. http://groups.google.com/group/clojure/browse_thread/thread/1e7b9c0a2d839bca/e1d6a0f1282c60d2?q=saving+the+Clojure+webiste The program, however, is terribly slow and inefficient. I've been working on impr

Re: Applying Java methods.

2009-09-23 Thread sross
On Sep 22, 2:30 pm, Chouser wrote: > On Mon, Sep 21, 2009 at 5:22 PM, sross wrote: > > > Hi All, > > >  I'm looking for a bit of advice for calling a java method which has a > > few different signatures (such as Connection.prepareStatement). > >  Is there a cleaner way of passing a variable numb

Re: trouble running clojure.test

2009-09-23 Thread Timothy Pratley
I think your environment is swallowing the output. What setup are you running? Try with just a blank REPL, this is what I get: foo=> (ns foo (:use [clojure.test])) nil foo=> (is (= 5 (+ 2 2))) FAIL in clojure.lang.persistentlist$emptyl...@1 (NO_SOURCE_FILE:6) expected: (= 5 (+ 2 2)) actual: (n

Re: Streaming Data?

2009-09-23 Thread Timothy Pratley
Tom Faulhaber wrote a great article which uses fill-queue to create a lazy-seq from a data stream, I think you might find it quite applicable: http://infolace.blogspot.com/2009/08/simple-webhooks-with-clojure-and-ring.html http://richhickey.github.com/clojure-contrib/seq-utils-api.html#fill-queue