Re: problem with threading and sql lib

2009-09-18 Thread Roger Gilliar
Hi, > re you opening something, using it to return a lazy sequence, and > then closing it before consuming the sequence? No. I started with just opening the database connection in the handler function. Regards Roger --~--~-~--~~~---~--~~ You received th

Re: How can a clojure script recognise it is running as a script?

2009-09-18 Thread David Nolen
So that you can write python code that can function both as a shell script and as a library transparently. On Fri, Sep 18, 2009 at 7:42 PM, ataggart wrote: > > Just for my own edification (not being versed in python), what's the > point of knowing that? > > > On Sep 18, 3:46 am, Kelvin Ward wro

Re: How can a clojure script recognise it is running as a script?

2009-09-18 Thread ataggart
Just for my own edification (not being versed in python), what's the point of knowing that? On Sep 18, 3:46 am, Kelvin Ward wrote: > java -cp clojure.jar clojure.main foo.clj > > I'm wondering if the code in foo.clj has anyway to know it is being > executed as a script. In python there's the id

Re: Silly Convention Question

2009-09-18 Thread Sean Devlin
For what it's worth, I try to follow the convention Rich uses in core f - for a function pred - for a predicate coll - for a collection body - for macro bodys name - symbol definition params - bindings Just my $.02 Sean On Sep 18, 6:37 pm, CuppoJava wrote: > John illustrates a common scenario

Re: Silly Convention Question

2009-09-18 Thread David Nolen
On Fri, Sep 18, 2009 at 6:37 PM, CuppoJava wrote: > > John illustrates a common scenario in Clojure. Clojure's built-in > functions are tersely and sensibly named. The problem is that there is > indeed a finite number of terse and sensible names... which bites you > when you need some of those nam

Re: Silly Convention Question

2009-09-18 Thread Laurent PETIT
My syntax highlighter makes it clear which symbols have similar names as clojure.core fns or vars : I have somewhat enforced the conventions not in the way to write the names (capitalized ..) but in the way to color them. So it is really easy to catch a color in a function or let parameter ... HTH

Re: Silly Convention Question

2009-09-18 Thread CuppoJava
John illustrates a common scenario in Clojure. Clojure's built-in functions are tersely and sensibly named. The problem is that there is indeed a finite number of terse and sensible names... which bites you when you need some of those names. Hence why in my code I have started to just capitalize v

Re: OutOfMemoryError with loop/recur

2009-09-18 Thread Laurent PETIT
2009/9/18 ajuc > > I was probably wrong - too many classes should throw error about > permGenSpace (at least in java they do). > Yes. A literal (fn) will only create one class. And returning it 100.000 times in a tight loop will create 100.000 instances of this class. > > Also for me it works

Re: OutOfMemoryError with loop/recur

2009-09-18 Thread Patrik Fredriksson
On Sep 18, 10:46 pm, John Harrop wrote: > On Fri, Sep 18, 2009 at 4:39 PM, Tassilo Horn wrote: > > > Although that doesn't really help, the normal `reduce' doesn't do > > better. > > > (reduce + (take 100 (iterate inc 1)))  ; works > > (reduce + (take 1000 (iterate inc 1))) ; OutOfMemoryE

Re: OutOfMemoryError with loop/recur

2009-09-18 Thread John Harrop
On Fri, Sep 18, 2009 at 3:52 PM, Patrik Fredriksson wrote: > > Hi! > > Could someone please help me understand why the following causes a > java.lang.OutOfMemoryError: Java heap space for large n:s (10 > works fine, 100 does not). > > (def integers (iterate inc 1)) > > (defn limited-reduce

Re: Silly Convention Question

2009-09-18 Thread John Harrop
On Fri, Sep 18, 2009 at 4:45 PM, CuppoJava wrote: > Hi, > After I shot myself in the foot again this morning by naming one of my > variables "cond" and then wondering why Clojure was complaining about > a simple cond form, I thought why don't we have capitalization > conventions that differ betwee

Re: OutOfMemoryError with loop/recur

2009-09-18 Thread John Harrop
On Fri, Sep 18, 2009 at 4:39 PM, Tassilo Horn wrote: > Although that doesn't really help, the normal `reduce' doesn't do > better. > > (reduce + (take 100 (iterate inc 1))) ; works > (reduce + (take 1000 (iterate inc 1))) ; OutOfMemoryError Are you sure? I'd expect that with (def integ

Re: Silly Convention Question

2009-09-18 Thread James Reeves
On Sep 18, 9:45 pm, CuppoJava wrote: > After I shot myself in the foot again this morning by naming one of my > variables "cond" and then wondering why Clojure was complaining about > a simple cond form, I thought why don't we have capitalization > conventions that differ between variables and fu

Re: Modeling question multimethods or methodmaps?

2009-09-18 Thread James Reeves
On Sep 17, 12:50 pm, Philipp Meier wrote: > Which way would you prefer? What are to advantaces and drawbacks of > each? The method-map approach seams more fp to me, but, I think that's > like how multimethods are impemented, aren't they? I've actually been considering factoring out Compojure's o

Re: OutOfMemoryError with loop/recur

2009-09-18 Thread Jonathan Smith
It would be kind of nice to have some sort of uniform identifier for laziness similar to ! for destructive and ? for predicate. On Sep 18, 5:10 pm, Raoul Duke wrote: > > Runs (in a nice constant memory) even though yours (which almost > > appears equivalent) will not! > > i am thinking ever more

Re: OutOfMemoryError with loop/recur

2009-09-18 Thread Raoul Duke
> Runs (in a nice constant memory) even though yours (which almost > appears equivalent) will not! i am thinking ever more that less than stupendously overt syntax for laziness is too risky cf. Haskell and Clojure. sincerely. --~--~-~--~~~---~--~~ You received th

Re: OutOfMemoryError with loop/recur

2009-09-18 Thread Jonathan Smith
http://www.haskell.org/haskellwiki/Performance These are the performance tips I was referring to. (4. General techniques, laziness, space leaks.) On Sep 18, 5:03 pm, Jonathan Smith wrote: > Hi! > > This is happening because you have integers saved to a global > variable. > > (iterate inc 1) cre

Re: OutOfMemoryError with loop/recur

2009-09-18 Thread Jonathan Smith
Hi! This is happening because you have integers saved to a global variable. (iterate inc 1) creates an infinite lazy seq. Def-fing it to a global says 'Hey, i might want this later!' to Clojure. This means that as you take numbers from integers; they get saved in memory rather than being garba

Re: OutOfMemoryError with loop/recur

2009-09-18 Thread Patrik Fredriksson
Hi, On Sep 18, 10:39 pm, Tassilo Horn wrote: > Patrik Fredriksson writes: > > Hi Patrick, > > > > > Could someone please help me understand why the following causes a > > java.lang.OutOfMemoryError: Java heap space for large n:s (10 > > works fine, 100 does not). > > > (def integers (it

Re: OutOfMemoryError with loop/recur

2009-09-18 Thread Patrik Fredriksson
On Sep 18, 10:35 pm, Jarkko Oranen wrote: > On Sep 18, 10:52 pm, Patrik Fredriksson wrote: > > > > > Hi! > > > Could someone please help me understand why the following causes a > > java.lang.OutOfMemoryError: Java heap space for large n:s (10 > > works fine, 100 does not). > > > (def

Silly Convention Question

2009-09-18 Thread CuppoJava
Hi, After I shot myself in the foot again this morning by naming one of my variables "cond" and then wondering why Clojure was complaining about a simple cond form, I thought why don't we have capitalization conventions that differ between variables and functions? Everything in Clojure is lowerca

Re: OutOfMemoryError with loop/recur

2009-09-18 Thread Tassilo Horn
Patrik Fredriksson writes: Hi Patrick, > Could someone please help me understand why the following causes a > java.lang.OutOfMemoryError: Java heap space for large n:s (10 > works fine, 100 does not). > > (def integers (iterate inc 1)) > > (defn limited-reduce [fn coll n] > (loop [c c

Re: OutOfMemoryError with loop/recur

2009-09-18 Thread ajuc
I was probably wrong - too many classes should throw error about permGenSpace (at least in java they do). Also for me it works for n=100, fails for 1000 (clojurebox 1.0). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Goog

Re: OutOfMemoryError with loop/recur

2009-09-18 Thread Jarkko Oranen
On Sep 18, 10:52 pm, Patrik Fredriksson wrote: > Hi! > > Could someone please help me understand why the following causes a > java.lang.OutOfMemoryError: Java heap space for large n:s (10 > works fine, 100 does not). > > (def integers (iterate inc 1)) > > (defn limited-reduce [fn coll n]

Re: OutOfMemoryError with loop/recur

2009-09-18 Thread ajuc
I'm beginner myself, but I' think it's because it creates 100 new classes (for each new anonymous fn). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@g

OutOfMemoryError with loop/recur

2009-09-18 Thread Patrik Fredriksson
Hi! Could someone please help me understand why the following causes a java.lang.OutOfMemoryError: Java heap space for large n:s (10 works fine, 100 does not). (def integers (iterate inc 1)) (defn limited-reduce [fn coll n] (loop [c coll i n result 0] (if (zero? i) result (rec

Re: problem with threading and sql lib

2009-09-18 Thread John Harrop
On Fri, Sep 18, 2009 at 1:32 PM, rogergl wrote: > The problem is that the above code only works if I establish a > connection outside the handle-client function. Otherwise the first > reply to my client gets lost. > > Has anyone an explanation for this ? Are you opening something, using it to r

Re: How can a clojure script recognise it is running as a script?

2009-09-18 Thread Kelvin Ward
Thanks for the help guys, I'll look at compilation. On Sep 18, 4:45 pm, Stuart Sierra wrote: > On Sep 18, 6:46 am, Kelvin Ward wrote: > > > java -cp clojure.jar clojure.main foo.clj > > > I'm wondering if the code in foo.clj has anyway to know it is being > > executed as a script. In python the

problem with threading and sql lib

2009-09-18 Thread rogergl
The first part of my code looks like this (defn handle-client [in out] (binding [ *in* (reader in) ] (with-connection db (let [outstream (writer out)] (loop []

Re: Anyone care to defend/comment some points in this presentation

2009-09-18 Thread John Harrop
On Fri, Sep 18, 2009 at 8:34 AM, Mark Volkmann wrote: > On Thu, Sep 17, 2009 at 5:22 PM, John Harrop wrote: > > On Thu, Sep 17, 2009 at 3:06 PM, Mark Volkmann < > r.mark.volkm...@gmail.com> > > wrote: > >> > >> On Thu, Sep 17, 2009 at 1:43 PM, z5h wrote: > >> > > >> > Specifically some problems

Re: Single method interface proxies

2009-09-18 Thread John Newman
I agree though, proxy is off-putting. It just looks so much less clean than the rest of Clojure. On Fri, Sep 18, 2009 at 6:43 PM, CuppoJava wrote: > > Hi Nikolay, > In my opinion it's hard to reduce the verbosity of proxy without > sacrificing some of its generality. For my own code I just made

Re: (+ clojure cascading)

2009-09-18 Thread Tom Faulhaber
We've moved the Bay Area Clojure Meetup so that we can all come crash your party instead. It sounds super-interesting, but I'm not sure my friends will be impressed :-). Tom On Sep 17, 8:50 pm, bradford cross wrote: > We're going to have a meetup on clojure and cascading and Rapleaf Sept > 24t

Re: loop-recur for string handling

2009-09-18 Thread Jonathan Smith
I find loop recur kind of hard to follow sometimes I was browsing through this pdf the other day: http://www.cs.umbc.edu/331/resources/papers/Evolution-of-Lisp.pdf And I found the tail recursive definition of common lisp/scheme style do. Thoroughly intrigued, I implemented it: (defmacro cl-

Re: I just posted a discussion of building webhooks in Clojure with Ring

2009-09-18 Thread Tom Faulhaber
Thanks! Corrected. On Sep 18, 1:32 am, James Reeves wrote: > On Sep 17, 11:35 pm, Tom Faulhaber wrote: > > > You can find it > > here:http://infolace.blogspot.com/2009/08/simple-webhooks-with-clojure-and... > > A small correction: Ring is inspired by Rack, not Sinatra. > > - James --~--~--

Re: How can a clojure script recognise it is running as a script?

2009-09-18 Thread Stuart Sierra
On Sep 18, 6:46 am, Kelvin Ward wrote: > java -cp clojure.jar clojure.main foo.clj > > I'm wondering if the code in foo.clj has anyway to know it is being > executed as a script. In python there's the idiom: This doesn't exist right now. The closest equivalent is: (ns my-namespace (:

Re: Modeling question multimethods or methodmaps?

2009-09-18 Thread Stuart Sierra
On Sep 17, 4:02 pm, Philipp Meier wrote: > > Not your question, I know, but the Restlet framework for Java does > > exactly this. > > I know ;-) And it's using object oriented inheritance. In common lisp > I'd use CLOS and an object hierachy but in clojure I'm unsure. I just use Restlet directl

Re: Can anyone here give a comparison between Clojure and Erlang on concurrent programming?

2009-09-18 Thread Stuart Sierra
On Sep 17, 6:54 pm, dongbo wrote: > Can any one give a comparison between Clojure and Erlang on concurrent > programming? Erlang supports one concurrency model, Actors. Clojure supports several -- Agents, which are similar to Actors; Refs, which have ACI (not D) transactional semantics; and Ato

Re: Redefining Special Forms

2009-09-18 Thread Constantine Vetoshev
On Sep 17, 2:55 pm, Chouser wrote: > In a new thread, vars always start with their root binding. > > There's an ongoing discussion about the best way to provide > other options when this is not the desired behavior: > > http://www.assembla.com/spaces/clojure/tickets/170-bound-fn-macro That discu

Re: Single method interface proxies

2009-09-18 Thread CuppoJava
Hi Nikolay, In my opinion it's hard to reduce the verbosity of proxy without sacrificing some of its generality. For my own code I just made a new_listener macro that simply returns a new actionListener for me. This worked fine since 99% of the time, I only use proxies for actionListeners anyway.

Re: frameworks

2009-09-18 Thread Brian
I thought the question was looking for the Clojure equivalent to Ruby on Rails (i.e. Conjure ). On Fri, Sep 18, 2009 at 9:54 AM, David Nolen wrote: > What do you mean by development frameworks? IDE support? > On Fri, Sep 18, 2009 at 8:08 AM, demet

Re: How can a clojure script recognise it is running as a script?

2009-09-18 Thread David Nolen
The source itself cannot know the way a Python knows. However you can understand how to achieve pretty much the same effect with the following: http://clojure.org/compilation On Fri, Sep 18, 2009 at 6:46 AM, Kelvin Ward wrote: > > java -cp clojure.jar clojure.main foo.clj > > I'm wondering if the

Re: Anyone care to defend/comment some points in this presentation

2009-09-18 Thread David Nolen
Click answers that himself: Clojure usage failure. The particular scenario he is demonstrating is known and has been brought up before. Also it's probably only reproduceable when you have a truly large number of cores (like a 600 way Azul box). In anycase Rich Hickey does not advise against locks w

Re: frameworks

2009-09-18 Thread David Nolen
What do you mean by development frameworks? IDE support? On Fri, Sep 18, 2009 at 8:08 AM, demet8 wrote: > > Im new to Clojure. Are there any development frameworks for clojure > worth noting yet? > > > > --~--~-~--~~~---~--~~ You received this message because you

Re: Single method interface proxies

2009-09-18 Thread Nikolay Petrov
Hi, Thanks that is good to know. However the origin of my problem was in implementing ActionListeners :) Best Regards, Nikolay Petrov On Sep 18, 3:59 pm, "David Powell" wrote: > > Hi, > > > I was thinking can we do some magic to easily implement single method > > interfaces? What i mean how ca

Re: Single method interface proxies

2009-09-18 Thread David Powell
> Hi, > > I was thinking can we do some magic to easily implement single method > interfaces? What i mean how can we reduce the noise in the following: > > (proxy [java.lang.Runnable] [] (run [] (println "running"))) FYI: For this specific case, the answer is fairly simple. Clojure fn's implem

Re: Anyone care to defend/comment some points in this presentation

2009-09-18 Thread Mark Volkmann
On Thu, Sep 17, 2009 at 5:22 PM, John Harrop wrote: > On Thu, Sep 17, 2009 at 3:06 PM, Mark Volkmann > wrote: >> >> On Thu, Sep 17, 2009 at 1:43 PM, z5h wrote: >> > >> > Specifically some problems encountered in Clojure's STM and bytecode >> > generation. >> > >> > >> > http://www.azulsystems.c

frameworks

2009-09-18 Thread demet8
Im new to Clojure. Are there any development frameworks for clojure worth noting yet? --~--~-~--~~~---~--~~ 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

Single method interface proxies

2009-09-18 Thread Nikolay Petrov
Hi, I was thinking can we do some magic to easily implement single method interfaces? What i mean how can we reduce the noise in the following: (proxy [java.lang.Runnable] [] (run [] (println "running"))) (proxy [java.util.concurrent.Executor] [] (execute [runner] (.run runner))) And settled on

How can a clojure script recognise it is running as a script?

2009-09-18 Thread Kelvin Ward
java -cp clojure.jar clojure.main foo.clj I'm wondering if the code in foo.clj has anyway to know it is being executed as a script. In python there's the idiom: def main(): ... if __name__ == "__main__": main() I can then import the file at the repl and execute main() only if want. I can a

Re: Anyone care to defend/comment some points in this presentation

2009-09-18 Thread Roberto Mannai
Also the slide 21 should worth an answer: a benchmark of STM with more CPU gives "Performance died – choked in the STM" On Fri, Sep 18, 2009 at 9:22 AM, Michael Wood wrote: > > 2009/9/17 z5h : > > > > Specifically some problems encountered in Clojure's STM and bytecode > > generation. > > > > >

Re: I just posted a discussion of building webhooks in Clojure with Ring

2009-09-18 Thread James Reeves
On Sep 17, 11:35 pm, Tom Faulhaber wrote: > You can find it > here:http://infolace.blogspot.com/2009/08/simple-webhooks-with-clojure-and... A small correction: Ring is inspired by Rack, not Sinatra. - James --~--~-~--~~~---~--~~ You received this message because

Re: Is knowing Java a prerequisite for using Clojure?

2009-09-18 Thread Emeka
Hugh, I receive Factor mails, however, I am still learning Forth/Factor. IMHO, you should spend much of your time in Java while casually going through Clojure book. Factor and Clojure are FP languages and I must confess they are close cousins. I have heard you mention gcode and other stuff in Fact

Re: Anyone care to defend/comment some points in this presentation

2009-09-18 Thread Michael Wood
2009/9/17 z5h : > > Specifically some problems encountered in Clojure's STM and bytecode > generation. > > http://www.azulsystems.com/events/javaone_2009/session/2009_J1_JVMLang.pdf > (Slide's 8 and 20-21) I suppose you mean slide 9 rather than 8: > Clojure - “almost close” > * Good: no obvious

Re: java/scala oneliner

2009-09-18 Thread Timothy Pratley
Nice one! :) On Sep 18, 4:47 pm, Adrian Cuthbertson wrote: > If y're Sco'ish... -> 59 > > (dotimes[i 4](println"Appy Birthdy"({2"D'r XXX"}i"To Ye"))) > Appy Birthdy To Ye > Appy Birthdy To Ye > Appy Birthdy D'r XXX > Appy Birthdy To Ye > > On Fri, Sep 18, 2009 at 6:35 AM, David Nolen wrote: >