Re: basic question on structuring refs
Hi Korny, That is a very interesting question to me, specifically this part: > how do I stop parallel > changes to two unrelated structures in the world from causing transaction > retries? Actually I don't think you can ever rule out retries if you are using a ref (or atom) and more than one thread to access it. For me this poses a problem because my 'transaction' has side-effects. I have a function which modifies the state, but it also reports the modification (reporting should only happen once). I can think of two solutions: (1) Use an agent instead - changes are coordinated on a queue and the modification is only run once. (2) Use watchers to do the reporting. Neither of these are particularly appealing to me as (1) is asynchronous and (2) appears to slightly complicate things. In my case it seems a regular old lock would be sufficient? There is a discussion on STM generally: http://groups.google.com/group/clojure/browse_thread/thread/822e21c9a36c5a0f/c81692a8dc1bd198 But I'm still a little unsure what I should do in this situation. Regards, Tim. --~--~-~--~~~---~--~~ 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 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: Possible Solution for Left-Right Precedence and More when using Multimethods? (was re: oo)
On 31.03.2009, at 21:48, Konrad Hinsen wrote: > On 31.03.2009, at 18:50, Mark Engelberg wrote: > >> On Tue, Mar 31, 2009 at 9:45 AM, Konrad Hinsen >> wrote: >>> I think this should be sufficient to cover all cases you mentioned, >>> but of course it needs to be tried in practice. >> >> I think your idea of specifying a sequence of items to try in the >> dispatching function, at the point of definition for the multimethod, >> violates the principle of allowing library consumers to easily extend >> this on their own without having to contact the library designer. > > Maybe I wasn't clear about one point: the return sequence is not the > sequence of concrete implementations to try (the dispatch function > wouldn't even necessarily know them), but a sequence of starting > points in the hierarchy from which the standard lookup would start. One night's sleep later, I see that this is not sufficient. The dispatch function is defined before the multimethod, and thus potentially inside some library, which cannot know all the needs of its potential clients. So yes, there has to be a way to specify preferences later on. One possibility would be to make the dispatch function itself a multimethod, or have it call one, but I am not sure that's a good solution. Konrad. --~--~-~--~~~---~--~~ 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 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: basic question on structuring refs
Hello Korny, I share your questioning. On 1 avr, 06:57, Korny Sietsma wrote: > (A) one ref for the whole world - in which case how do I stop parallel > changes to two unrelated structures in the world from causing transaction > retries? In this case, I wonder whether to extend "ensure" so as to be able to ensure an invariant over a ref would be a good idea. eg: (ensure world f arg1 arg2) ; compute (f @world arg1 arg2) ; (commute world g arg3 arg4) ; commute iff (f @world arg1 arg2) still returns the same value. Christophe --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
Advanced Practical Recursion in Lisp 1.0
Just last week I finally got my "Advanced Practical Recursion in Lisp 1.0" kit from Y-Combinator Technologies, Inc. (not Paul Graham's company). They have this amazing product that I think we can use in Clojure. I'm not supposed to share the source code, but I can trust you folks right? The main component is this function Y: (defn Y [m] ((fn [future] (m (fn [arg] ((future future) arg (fn [future] (m (fn [arg] ((future future) arg )) You can use this to define anonymous recursive functions. "Why would I want to do that?", you ask yourself. Well, let me tell you why. Ordinarily we would define a recursive function like this: (defn factorial [n] (if (zero? n) 1 (* n (factorial (dec n ) The function body naturally contains a reference to itself--'factorial'-- in order to compute the recursive cases. But what if we wanted to apply an anonymous recursive function directly to an argument: ((fn [n] (if (zero? n) 1 (* n (?? (dec n) 6) What do we put where the ?? is? This function has no name, so how can it call itself? That's where "Advanced Practical Recursion in Lisp 1.0" (APRiL 1.0) comes in! Using the function Y above, the problem disappears: ((Y (fn [rec] (fn [n] (if (zero? n) 1 (* n (rec (dec n ))) 6) => 720 What could be simpler than that? Here are a few more familiar examples. Fibonacci numbers? No problem: ((Y (fn [rec] (fn [n] (cond (= n 0) 0 (= n 1) 1 :else (+ (rec (- n 1)) (rec (- n 2 ))) 10) => 55 Find the length of a list: ((Y (fn [rec] (fn [l] (if (empty? l) 0 (inc (rec (rest l ))) '(a b c d e)) => 5 How about reversing a list? This one's really recursive (quadruply)! ((Y (fn [rec] (fn [l] (cond (empty? l) '() (empty? (rest l)) (list (first l)) :else (cons (first (rec (rest l))) (rec (cons (first l) (rec (rest (rec (rest l ))) '(a b c d e)) => (e d c b a) There's even an experimental version of Y that can handle anonymous functions with multiple parameters: (defn Y2 [m] ((fn [future] (m (fn [& args] (apply (future future) args (fn [future] (m (fn [& args] (apply (future future) args )) Using this we can remove elements that we don't want from a list: ((Y2 (fn [rec] (fn [obj l] (cond (empty? l) '() (= (first l) obj) (rec obj (rest l)) :else (cons (first l) (rec obj (rest l ))) 'pung '(pung foo bar baz pung baz bar pung foo)) => (foo bar baz baz bar foo) Replace certain elements in a list: ((Y2 (fn [rec] (fn [new old l] (cond (empty? l) '() (= (first l) old) (cons new (rec new old (rest l))) :else (cons (first l) (rec new old (rest l ))) 'pung 'foo '(pung foo bar baz pung bar foo)) => (pung pung bar baz pung bar pung) Or in an arbitrary tree: ((Y2 (fn [rec] (fn [new old obj] (cond (= obj old) new (and (coll? obj) (seq obj)) (cons (rec new old (first obj)) (rec new old (rest obj))) :else obj 'a 'b '(a ((b) c (a b c)) d (a b))) => (a ((a) c (a a c)) d (a a)) Now here's the exciting part. I'm trying to work out some sort of licensing deal for us. If the price is right we can use APRiL 1.0 to streamline Clojure code. For instance, we won't need 'map' anymore: ((Y2 (fn [rec] (fn [f l] (if (empty? l) '() (cons (f (first l)) (rec f (rest l ))) inc (range 10)) => (1 2 3 4 5 6 7 8 9 10) ((Y2 (fn [rec] (fn [f l] (if (empty? l) '() (cons (f (first l)) (rec f (rest l ))) #(.toUpperCase %) '("Is" "this" "not" "pung?")) => ("IS" "THIS" "NOT" "PUNG?") But wait, there's more!! We won't need 'reduce' either: ((Y2 (fn [rec] (fn [f start l] (if (empty? l) start (f (first l) (rec f start (rest l ))) + 0 [1 2 3 4 5]) => 15 ((Y2 (fn [rec] (fn [f start l] (if (empty? l) start (f (first l) (rec f start (rest l ))) * 1 [1 2 3 4 5 6]) => 720 I hope that you can start to see the potential here! There are no doubt many other superfluous operators just clogging up Clojure that you'd rather live without (No offense, Rich. I'm sure you tried your best. :-) ). I'm eager to hear your suggestions!! I'm optimistic that the company is willing to work with us, but if their price is too high they do have another cheaper option. There is a reduced rate anonymous Y function as well. Even Y doesn't need a name--we just use it directly. Cut out the middleman and everyone wins! Here's 'le
Re: Setting up Clojure on OS X
Just a quick note to say that I've added notes about the TextMate Clojure bundle to my tutorial. I've also put a concise version of the guide up on GitHub: http://github.com/mreid/clojure-framework/tree/master Regards, Mark. -- http://mark.reid.name --~--~-~--~~~---~--~~ 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 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: basic question on structuring refs
I came across a thread from Jul '08 which seems to be the definitive on handling side-effects within transactions - http://groups.google.co.za/group/clojure/browse_thread/thread/d645d77a8b51f01/667e833c1ea381d7 Adrian. On Wed, Apr 1, 2009 at 9:24 AM, Timothy Pratley wrote: > > Hi Korny, > > > That is a very interesting question to me, specifically this part: > >> how do I stop parallel >> changes to two unrelated structures in the world from causing transaction >> retries? > > Actually I don't think you can ever rule out retries if you are using > a ref (or atom) and more than one thread to access it. For me this > poses a problem because my 'transaction' has side-effects. I have a > function which modifies the state, but it also reports the > modification (reporting should only happen once). I can think of two > solutions: > (1) Use an agent instead - changes are coordinated on a queue and the > modification is only run once. > (2) Use watchers to do the reporting. > Neither of these are particularly appealing to me as (1) is > asynchronous and (2) appears to slightly complicate things. In my case > it seems a regular old lock would be sufficient? > > There is a discussion on STM generally: > http://groups.google.com/group/clojure/browse_thread/thread/822e21c9a36c5a0f/c81692a8dc1bd198 > But I'm still a little unsure what I should do in this situation. > > > Regards, > Tim. > > > > > --~--~-~--~~~---~--~~ 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 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 Users Group - Denmark
On Mar 31, 11:33 pm, Attila Babo wrote: > Hey, here is another clojure user from Copenhagen. I'm a Hungarian but > living here so please count me in! Cool. I guess I will be arranging our first meeting at JAOO. Keep an eye on the site for other dcug news. -- Karl --~--~-~--~~~---~--~~ 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 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: Advanced Practical Recursion in Lisp 1.0
On Wed, Apr 1, 2009 at 6:00 AM, David Sletten wrote: > [snip] > > Here's 'length' again: > (((fn [m] > ((fn [future] >(m (fn [arg] > ((future future) arg > (fn [future] >(m (fn [arg] > ((future future) arg )) > (fn [rec] > (fn [l] > (if (empty? l) > 0 > (inc (rec (rest l ))) > '(a b c d e)) > => 5 > > And 'reverse': > (((fn [m] > ((fn [future] >(m (fn [arg] > ((future future) arg > (fn [future] >(m (fn [arg] > ((future future) arg )) > (fn [rec] > (fn [l] > (cond (empty? l) '() > (empty? (rest l)) (list (first l)) > :else (cons (first (rec (rest l))) > (rec (cons (first l) >(rec (rest (rec (rest l ))) > '(a b c d e)) > => (e d c b a) > > Breathtaking in its elegance! > Indeed! :) > > I'm going to move forward with the negotiations, but I need to know > if you, the Clojure community, are on board here. Ultimately the > decision is going to come down to whether or not you find the APRiL > 1.0 technology useful. Try it out and let me know your opinions. > I think I'll wait for APRiL 2.0. I often find that when I jump right into version 1.0 of a product, I'm made a fool! > > Aloha, > David Sletten > Paul --~--~-~--~~~---~--~~ 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 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: basic question on structuring refs
On Apr 1, 5:46 am, Christophe Grand wrote: > Hello Korny, > > I share your questioning. > > On 1 avr, 06:57, Korny Sietsma wrote: > > > (A) one ref for the whole world - in which case how do I stop parallel > > changes to two unrelated structures in the world from causing transaction > > retries? > > In this case, I wonder whether to extend "ensure" so as to be able to > ensure an invariant over a ref would be a good idea. > eg: > > (ensure world f arg1 arg2) ; compute (f @world arg1 arg2) > ; > (commute world g arg3 arg4) ; commute iff (f @world arg1 arg2) still > returns the same value. > Interesting - I'll think about it. Off the top of my head I'm concerned about the use of commute - it's not really commute if you need to ensure that something hasn't changed. Also, there will be a lot of pressure on the root, and need for history, even if the mechanism avoids retries. You would only consider this if the need to see the world as a single value dominated other concerns. Until then, I recommend option C. Korny really has two things here - the set (please, anything but list) of identities that constitutes the world, and those identities themselves. Rich --~--~-~--~~~---~--~~ 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 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 Users Group - Denmark
Another Danish user here, I am in Copenhagen. I can only support the initiative but i dont think it will be possible to put so much effort into it. I am mostly a casual user, using clojure for ad hoc processing / conversion of various text file formats (like edifact, swift, xml ..) in connection with my work as an IT consultant in the SAP area. I find clojure to be a really great tool for this kind of thing: - quck to work with - access to java libraries - universally available, because java is there. Just drop the clojure jar and you are running - no discussions about installing stuff... So keep up the good work :-) --~--~-~--~~~---~--~~ 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 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: basic question on structuring refs
On Apr 1, 6:57 am, Korny Sietsma wrote: > I have a world that is a list of structures > > The world itself will change occasionally - i.e. I'll add or remove > structures from the overall list, and I'll regularly be reading the whole > list. > (C) both of the above - a ref for the "world" list which itself contains a > list of refs to each structure I believe this is the way to go. Compare it with Rich's ants colony simulation (http://clojure.googlegroups.com/web/ants.clj? gda=wt5HfzoAAAC2LrkjeC7f10uHiY7GOiyxxoot- tFsZ2hOJiGaR1IofO9OU0NQiFWgQuhmPR7veGf97daDQaep90o7AOpSKHW0">ants.clj. He defines a 2D world of refs: ;world is a 2d vector of refs to cells (def world (let [mk_vec (fn [x] (apply vector x)) mk_cell (fn [_] (ref (struct cell 0 0))) dim_seq (range dim)] ;(0,...,dim) (mk_vec (map (fn [_] (mk_vec (map mk_cell dim_seq))) dim_seq Your case is simpler since you just need a single array: (def dim 42);initial world size (def world (let [mk_vec (fn [x] (apply vector x)) mk_cell (fn [_] (ref (struct cell 0 0))) ;;replace with your struct dim_seq (range dim)] ;(0,...,dim) (mk_vec (map mk_cell dim_seq))) ;;note I didn't test this code I think this would work for you. -- Karl --~--~-~--~~~---~--~~ 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 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: Advanced Practical Recursion in Lisp 1.0
On Wed, Apr 1, 2009 at 12:00 PM, David Sletten wrote: > [snip] > I'm going to move forward with the negotiations, but I need to know > if you, the Clojure community, are on board here. Ultimately the > decision is going to come down to whether or not you find the APRiL > 1.0 technology useful. Try it out and let me know your opinions. This technology is too cool to be true! I'll chip in and donate all my spare parens (thanks Rich)! Remco --~--~-~--~~~---~--~~ 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 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: -> vs. comp
While we speak about function composition (or not), you can also use the partial function creator to obtain "point-free" (no need for anonymous function with formal argument declaration or use) code: And with the use of comp, you could define the function without even explicitly naming any formal argument :-) : 1:7 user=> (def deep-csv (comp (partial apply println) (partial interpose ", ") seq-utils/flatten)) #'user/deep-csv 1:10 user=> (deep-csv '((1 2 3) (4 5 6))) 1 , 2 , 3 , 4 , 5 , 6 nil For one-shot expression threading, I agree with David that -> would be more approriate, though the need to enclose the anonymous function definitions in extraneous parenthesis is not so lisible, even with short forms of anonymous function definitions: (defn deep-csv [mr] (-> mr flatten (#(interpose ", " %)) (#(apply println % My 0,02€, -- Laurent 2009/4/1 kkw > > Hi folks, > >I have some code where I wanted to: > - take a list of stuff (which includes another list inside) > - use 'seq-utils/flatten' to flatten the list > - use 'interpose' to add comma-delimiting strings between the elements > - print out the results, thereby creating comma-delimited output > >I may choose between: > > ((comp > (fn [x] (apply println x)) > (fn [x] (interpose ", " x)) > seq-utils/flatten) > mr) > > OR > > (-> mr >seq-utils/flatten >((fn [x] (interpose ", " x))) >((fn [x] (apply println x > >And I found the "->" notation marginally easier to interpret and > understand. Apart from appearance, are there any benefits to using -> > instead of the comp function? I happily concede that there exist nicer > ways to achieve this goal, but the question I wanted to raise > concerned the benefits of using -> vs comp or vice-versa. > > Kev > > Kev > > > --~--~-~--~~~---~--~~ 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 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: -> vs. comp
comp seems more appropriate here. On Mar 31, 11:52 pm, kkw wrote: > Hi folks, > > I have some code where I wanted to: > - take a list of stuff (which includes another list inside) > - use 'seq-utils/flatten' to flatten the list > - use 'interpose' to add comma-delimiting strings between the elements > - print out the results, thereby creating comma-delimited output > > I may choose between: > > ((comp > (fn [x] (apply println x)) > (fn [x] (interpose ", " x)) > seq-utils/flatten) > mr) > > OR > > (-> mr > seq-utils/flatten > ((fn [x] (interpose ", " x))) > ((fn [x] (apply println x > > And I found the "->" notation marginally easier to interpret and > understand. Apart from appearance, are there any benefits to using -> > instead of the comp function? I happily concede that there exist nicer > ways to achieve this goal, but the question I wanted to raise > concerned the benefits of using -> vs comp or vice-versa. > > Kev > > Kev --~--~-~--~~~---~--~~ 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 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: Possible Solution for Left-Right Precedence and More when using Multimethods? (was re: oo)
On Mar 31, 12:45 pm, Konrad Hinsen wrote: > On Mar 31, 2009, at 16:32, Rich Hickey wrote: > > > Here are some problems/limitations of existing OO/GF systems that I > > don't intend to repeat: > > ... > > I agree that these are not desirable features. I have had to work > around some of them many times in the past. Traditional OO combines > aspects that should better be handled separately. > > > Here are the areas I'm looking to improve: > > > - There's no easy way to talk about "the method you would get if you > > were dispatch value X". Note that this is not the same as call-next- > > method, which reintroduces global ordering requirements, but allows > > for easy explicit reuse of already-defined methods. > > That would be VERY nice to have. More than once I ended up writing a > private function that I then called from several methods in the same > multimethod, to avoid code duplication. > I've added get-method (SVN 1338). (derive ::Circle ::Shape) (derive ::Rect ::Shape) (defmulti area :Shape) ;note - you can name methods (defmethod area ::Shape area-shape [x] nil) (get-method area ::Rect) # (defmethod area ::Rect area-rect [r] (* (:wd r) (:ht r))) (defmethod area ::Circle area-circ [c] (* (. Math PI) (* (:radius c) (:radius c (get-method area ::Rect) # (get-method area ::Circ) ;not there nil (get-method area ::Circle) # ;if you don't think squares are rectangles, you can still reuse implementation (silly example) (defmethod area ::Square area-square [sqr] ((get-method area ::Rect) {:wd (:dim sqr) :ht (:dim sqr)})) (area {:Shape ::Square :dim 20}) 400 Note how you can name methods for diagnostic purposes. This doesn't introduce names into the namespace, just puts a name on the fn object. Rich --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
A clojure server
Hi, I wanted to use clojure for some scripting-like tasks (mostly experimenting with clojure's abilities). But I found, that clojure's startup time is too bad to do that. So I implemented a client-server architecture which works pretty much like clojure's default clojure.main. I'd be glad if you would try it and give me some feedback. The code can be found at http://github.com/Neronus/clj-server/tree/master Regards, Christian --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
Interaction of macros and special forms
I've been going through Stuart Halloway's book, _Programming Clojure_, and thinking about his deftarget macro has brought up some questions as to how macros and special forms interact in clojure. The deftarget macro needs to produce a "def" form that has metadata on its first argument, which is a symbol. Typically this is done with a reader macro, e.g. (def #^{:foo "bar"} x ...), but reader macros are problematic inside of (regular) macros, as they are executed before macro expansion. Stuart's solution involves doing some gensyms, but I thought it would be nice to just have a form of def what was more macro friendly. So I defined (defmacro def-with-md [md sym & optional-init] `(def ~(with-meta sym md) ~...@optional-init)) which means I can now write things like (defmacro foo [...] `(let [a# (...)] (def-with-md {:a a#} x (... This got me thinking about whether I could attack the problem even more directly. I defined another macro: (defmacro wmd [s md] (with-meta s md)) Trying it out: (macroexpand '(wmd x {:a 1})) ==> x But (def (wmd x {:a 1}) 37) gives me an error: "Second argument to def must be a Symbol". This confuses me. Doesn't macro expansion happen entirely before evaluation? So before the def special form is evaluated, (wmd x {:a 1}) should have already been macro expanded to give a symbol. (And why is it talking about the *second* argument, instead of the *first*?) --~--~-~--~~~---~--~~ 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 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: Possible Solution for Left-Right Precedence and More when using Multimethods? (was re: oo)
On Apr 1, 2009, at 14:47, Rich Hickey wrote: > I've added get-method (SVN 1338). Great, thanks! > Note how you can name methods for diagnostic purposes. This doesn't > introduce names into the namespace, just puts a name on the fn object. It's also useful for recursive calls, if you are sure you want to stay inside the method and not do a new dispatch. Konrad. --~--~-~--~~~---~--~~ 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 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: A clojure server
On Wed, Apr 1, 2009 at 8:28 AM, christ...@mvonessen.de wrote: > > Hi, > > I wanted to use clojure for some scripting-like tasks (mostly > experimenting with clojure's abilities). You might be interested in taking a look at nailgun: http://www.martiansoftware.com/nailgun/index.html. For example, the jruby folks use it, since they need to run all those scripts needed by Ruby on Rails. Cheers, Victor R. > But I found, that clojure's startup time is too bad to do that. > So I implemented a client-server architecture which works pretty much > like clojure's default > clojure.main. > I'd be glad if you would try it and give me some feedback. > The code can be found at http://github.com/Neronus/clj-server/tree/master > > Regards, > > Christian > > > > --~--~-~--~~~---~--~~ 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 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: Interaction of macros and special forms
On Apr 1, 2009, at 16:28, Kevin Van Horn wrote: > But > >(def (wmd x {:a 1}) 37) > > gives me an error: "Second argument to def must be a Symbol". This > confuses me. Doesn't macro expansion happen entirely before > evaluation? So before the def special form is evaluated, (wmd x {:a > 1}) should have already been macro expanded to give a symbol. Special forms are treated pretty much like macros, except that there is nothing more fundamental they expand to, instead they are handled directly by the compiler. But for the purpose of analyzing why your example doesn't work, let's pretend that def is a macro. The compiler sees "def" as the first element of a list, and notes that def is a macro (as we are pretending it is). It thus calls the def macro with the rest of the list elements as arguments. The first argument to def is (wmd x {:a 1}), the second argument is 37. As you can see, the first argument is indeed not a symbol, it is a list of three elements, wmd, x, and {:a 1}. And that's why def rightly complains - though I can't tell you why it says "second" instead of "first" argument. An important point to note about macros (and special forms) is that they are expanded from the outside inwards, contrary to expression evaluation, which starts at the innermost arguments and proceeds outward. It has to be like that because otherwise a macro couldn't fully define the syntax of its arguments. A macro might well expect one of its arguments to be a list with a specific format. If that argument were macroexpanded first, the outer macro would lose control. In your example, the wmd macro is thus not expanded at all, UNLESS the def macro copies it somewhere into its output form, which is then subjected to another round of macro expansion. Konrad. --~--~-~--~~~---~--~~ 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 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: Advanced Practical Recursion in Lisp 1.0
I like it, though I would prefer the more concise function "y" (lower case). --~--~-~--~~~---~--~~ 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 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: I need help tracking down a performance problem.
No change. I think made a small script that spends a large amount of time in java.lang.reflect.Array.setInt too: (set! *warn-on-reflection* true) (time (dotimes [_ 1] (let [#^ints arr (int-array 200)] (dotimes [i 200] (aset-int arr i i) So maybe I should try to see what I can do about other functions. On Mar 31, 11:04 pm, David Nolen wrote: > 15.1% 0 + 1711 java.lang.reflect.Array.setInt > Is definitely pointing at the aset-int as being the time gobbler, I think > the expression in the macro should be this > > (aset-int (ints arr#) i# (int (~mask-fn (. buf# (~get-fn) > > to be extra safe. > > On Tue, Mar 31, 2009 at 10:00 PM, Vincent Foley wrote: > > > I tried it just now; it made no difference. Nevertheless, thank you > > for you help and time! > > > On Mar 31, 9:38 pm, David Nolen wrote: > > > Did you try > > > (int (mask8 (. buf__2572__auto__ (get > > > > ? > > > > Your macro should like this: > > > > (defmacro make-reader > > > [get-fn mask-fn] > > > `(fn [#^ByteBuffer buf# len#] > > > (if (= len# 1) > > > (~mask-fn (. buf# (~get-fn))) > > > (let [#^"[I" arr# (int-array len#)] > > > (dotimes [i# len#] > > > (aset-int arr# i# (int (~mask-fn (. buf# (~get-fn)) > > > arr# > > > > On Tue, Mar 31, 2009 at 9:09 PM, Vincent Foley wrote: > > > > > I tried surrounding the call to the (. buf# (get)) method and putting > > > > the coercion directly inside the mask8 and mask16 functions. Neither > > > > worked. I want to mention at this point that I have *warn-on- > > > > reflection* set to true for the little script that uses the library > > > > and it doesn't report any call to methods that it can't resolve. > > > > > Here's the complete -Xprof output, if it helps. > > > > > Flat profile of 176.10 secs (11351 total ticks): main > > > > > Interpreted + native Method > > > > 4.5% 511 + 0 java.lang.Integer.hashCode > > > > 1.4% 160 + 0 java.lang.Integer.intValue > > > > 0.8% 91 + 0 starcraft.replay.unpack > > > > $decode_command_block__94.invoke > > > > 0.7% 80 + 0 clojure.lang.Numbers.int_array > > > > 0.2% 25 + 0 clojure.lang.PersistentVector.pushTail > > > > 0.1% 15 + 2 java.lang.ClassLoader.defineClass1 > > > > 0.1% 16 + 0 > > > > hu.belicza.andras.bwhf.control.BinReplayUnpacker.esi28 > > > > 0.1% 4 + 11 clojure.core__init.load > > > > 0.1% 10 + 0 clojure.lang.PersistentVector.cons > > > > 0.1% 8 + 0 starcraft.replay.actions$fn__71.invoke > > > > 0.1% 8 + 0 > > > > hu.belicza.andras.bwhf.control.BinReplayUnpacker.unpackSection > > > > 0.1% 0 + 7 java.lang.reflect.Array.setInt > > > > 0.1% 7 + 0 clojure.lang.PersistentHashMap > > > > $BitmapIndexedNode.create > > > > 0.1% 7 + 0 clojure.lang.RestFn.invoke > > > > 0.1% 7 + 0 clojure.lang.RestFn.invoke > > > > 0.1% 7 + 0 starcraft.replay.unpack > > > > $decode_commands__99.invoke > > > > 0.1% 7 + 0 starcraft.replay.parse > > > > $parse_buffer__53$fn__56.invoke > > > > 0.1% 6 + 0 clojure.lang.AFn.applyToHelper > > > > 0.1% 6 + 0 clojure.lang.PersistentArrayMap.assoc > > > > 0.1% 6 + 0 clojure.lang.PersistentHashMap > > > > $BitmapIndexedNode.assoc > > > > 0.0% 0 + 5 java.lang.reflect.Array.newArray > > > > 0.0% 0 + 5 java.lang.Class.forName0 > > > > 0.0% 0 + 5 java.util.zip.Inflater.inflateBytes > > > > 0.0% 5 + 0 java.lang.AbstractStringBuilder. > > > > 0.0% 5 + 0 java.util.Arrays.copyOfRange > > > > 10.9% 1157 + 76 Total interpreted (including elided) > > > > > Compiled + native Method > > > > 10.4% 1183 + 1 starcraft.replay.parse$fn__23$fn__49.invoke > > > > 10.0% 1123 + 17 starcraft.replay.unpack > > > > $decode_command_block__94.invoke > > > > 9.2% 1043 + 0 clojure.core$next__3096.invoke > > > > 8.9% 1014 + 0 starcraft.replay.parse > > > > $parse_buffer__53$fn__56.invoke > > > > 5.5% 626 + 0 clojure.lang.PersistentArrayMap.assoc > > > > 4.3% 474 + 17 clojure.lang.PersistentArrayMap.assoc > > > > 4.1% 464 + 7 clojure.lang.RestFn.invoke > > > > 2.9% 333 + 0 clojure.lang.Cons.next > > > > 2.5% 288 + 0 clojure.lang.RT.seq > > > > 2.4% 269 + 0 clojure.lang.AFn.applyToHelper > > > > 2.2% 249 + 0 > > > > hu.belicza.andras.bwhf.control.BinReplayUnpacker.unpackRepChunk > > > > 1.8% 202 + 0 clojure.core$seq__3112.invoke > > > > 1.6% 174 + 3 clojure.lang.RestFn.applyTo > > > > 1.3% 140 + 2 clojure.lang.APersistentMap.cons > > > > 1.2% 130 + 1 clojure.core$spread__3225.invoke > > > > 1.1% 127 + 0 clojure.lang.PersistentStructMap.valAt > > > > 0.8% 93 + 0 clojure.co
Re: A clojure server
On Wed, Apr 01, 2009 at 10:42:02AM -0400, Victor Rodriguez wrote: > > On Wed, Apr 1, 2009 at 8:28 AM, christ...@mvonessen.de > wrote: > > > > Hi, > > > > I wanted to use clojure for some scripting-like tasks (mostly > > experimenting with clojure's abilities). > > You might be interested in taking a look at nailgun: > http://www.martiansoftware.com/nailgun/index.html. > > For example, the jruby folks use it, since they need to run all those > scripts needed by Ruby on Rails. > While this looks really good, they provide no mechanism for authentication and user identification. I tried to achieve exaclty that with my file based authentication. Maybe I'll extend the code to do that. The project looks pretty dead to me, though Christian --~--~-~--~~~---~--~~ 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 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: A clojure server
On Apr 1, 2009, at 16:42, Victor Rodriguez wrote: > You might be interested in taking a look at nailgun: > http://www.martiansoftware.com/nailgun/index.html. I had tried nailgun a while ago, and still use it from time to time, but I found that for code development it has a significant disadvantage: since the loaded classes stay in memory, I can't start with a clean copy of Clojure without restarting the server first. Even the namespace "user" conserves all its definitions between invocations. This may well be a feature for some, but for testing code, I'd very much prefer to have a fresh instance of Clojure. I haven't tried Christian's Clojure-specific server yet, but if it solves that problem, I'll probably adopt it. Konrad. --~--~-~--~~~---~--~~ 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 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: Possible Solution for Left-Right Precedence and More when using Multimethods? (was re: oo)
Very cool. On Wed, Apr 1, 2009 at 8:47 AM, Rich Hickey wrote: > > > I've added get-method (SVN 1338). > > (derive ::Circle ::Shape) > (derive ::Rect ::Shape) > > (defmulti area :Shape) > > ;note - you can name methods > (defmethod area ::Shape area-shape [x] nil) > > (get-method area ::Rect) > # > > (defmethod area ::Rect area-rect [r] >(* (:wd r) (:ht r))) > (defmethod area ::Circle area-circ [c] >(* (. Math PI) (* (:radius c) (:radius c > > (get-method area ::Rect) > # > > (get-method area ::Circ) ;not there > nil > > (get-method area ::Circle) > # > > ;if you don't think squares are rectangles, you can still reuse > implementation (silly example) > (defmethod area ::Square area-square [sqr] > ((get-method area ::Rect) {:wd (:dim sqr) :ht (:dim sqr)})) > > (area {:Shape ::Square :dim 20}) > 400 > > Note how you can name methods for diagnostic purposes. This doesn't > introduce names into the namespace, just puts a name on the fn object. > > Rich > > > > --~--~-~--~~~---~--~~ 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 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: Request for improved error reporting
On Mar 28, 8:24 pm, Stuart Sierra wrote: [snip] > > Also, if you're using SLIME, you lose line numbers every time you > evaluate a form in the buffer. Type > (require your.namespace :reload) at the REPL to get them back. > This advice did not work for a situation I am encountering now and encounter frequently. I did 'require with :reload, even :reload-all, but I still have no idea what line in my source raised this exception. A line number would be dang useful here :) java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.IFn (NO_SOURCE_FILE:0) [Thrown class clojure.lang.Compiler$CompilerException] Restarts: 0: [ABORT] Return to SLIME's top level. 1: [CAUSE] Throw cause of this exception Backtrace: 0: clojure.lang.Compiler.eval(Compiler.java:4533) 1: clojure.core$eval__3969.invoke(core.clj:1738) --more-- On Mar 28, 8:24 pm, Stuart Sierra wrote: > On Mar 28, 7:55 pm, Glen Stampoultzis wrote: > > > I recently got this one that left me scratching my head: > > > java.lang.NullPointerException (splat.clj:0) > > at clojure.lang.Compiler.eval(Compiler.java:4533) > > In my experience, anerrorat line 0 means something wrong with the > (ns...) call at the top of the file. Try copying it into the REPL and > see if that sheds any light on the problem. > > Also, if you're using SLIME, you lose line numbers every time you > evaluate a form in the buffer. Type > (require your.namespace :reload) at the REPL to get them back. > > There are several stack trace llbs, including one in contrib, that > will give you (slightly) nicer stack traces. > > -Stuart Sierra --~--~-~--~~~---~--~~ 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 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: Questions about Clojure and Common Lisp
I can't give you any numbers on #2, but I have used both languages and there is no comparison. Groovy is freakishly slow. Clojure is relatively zippy. On Wed, Apr 1, 2009 at 11:41 AM, Chanwoo Yoo wrote: > > Hello. Yesterday, I talked with a representative of a publisher about > a translation of Lisp books. There are books about Ruby, Lua, Erlang, > and Groovy in South Korea, but there is no book about Lisp except > SICP. So he is considering printing the first Lisp book in South > Korea. We talked about 'Programming Clojure', 'ANSI Common Lisp', and > 'Practical Common Lisp'. I told him that I slightly prefered > 'Programming Clojure' to others because of Clojure's support for > concurrency and java interoperability. I said that the strong points > of Clojure would make programmers of main stream languages have > interests in Lisp. And he asked me questions like follows. > > 1. Has Clojure become stable? > He is afraid that the publishing of 'Programming Clojure' would be > meaningless if Clojure take significant changes after the publishing. > We know it will change. But the degree is the matter. > > 2. Could I get any benchmarking data about the performance of Clojure > and Java? > I read that Clojure can generate code as fast as Java in 'Programming > Clojure'. But he worries whether Clojure is slow like Groovy. Could I > get data about performance comparisons between Clojure and Java on > several algorithms? > > 3. Clojure can use Java libraries. Common Lisp can use C/C++ > libraries. Is it possible to say Clojure has strong points to Common > Lisp in the power of libraries? > > All these questions are not easy to answer for me. I think I should > give him the object information. So I hope that I get opinions from > the community. > > > > --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
Questions about Clojure and Common Lisp
Hello. Yesterday, I talked with a representative of a publisher about a translation of Lisp books. There are books about Ruby, Lua, Erlang, and Groovy in South Korea, but there is no book about Lisp except SICP. So he is considering printing the first Lisp book in South Korea. We talked about 'Programming Clojure', 'ANSI Common Lisp', and 'Practical Common Lisp'. I told him that I slightly prefered 'Programming Clojure' to others because of Clojure's support for concurrency and java interoperability. I said that the strong points of Clojure would make programmers of main stream languages have interests in Lisp. And he asked me questions like follows. 1. Has Clojure become stable? He is afraid that the publishing of 'Programming Clojure' would be meaningless if Clojure take significant changes after the publishing. We know it will change. But the degree is the matter. 2. Could I get any benchmarking data about the performance of Clojure and Java? I read that Clojure can generate code as fast as Java in 'Programming Clojure'. But he worries whether Clojure is slow like Groovy. Could I get data about performance comparisons between Clojure and Java on several algorithms? 3. Clojure can use Java libraries. Common Lisp can use C/C++ libraries. Is it possible to say Clojure has strong points to Common Lisp in the power of libraries? All these questions are not easy to answer for me. I think I should give him the object information. So I hope that I get opinions from the community. --~--~-~--~~~---~--~~ 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 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: Questions about Clojure and Common Lisp
> 3. Clojure can use Java libraries. Common Lisp can use C/C++ > libraries. Is it possible to say Clojure has strong points to Common > Lisp in the power of libraries? Accessing Java from Clojure is easier & more transparent than accessing C from Common Lisp. Joshua On Wed, Apr 1, 2009 at 6:41 PM, Chanwoo Yoo wrote: > > Hello. Yesterday, I talked with a representative of a publisher about > a translation of Lisp books. There are books about Ruby, Lua, Erlang, > and Groovy in South Korea, but there is no book about Lisp except > SICP. So he is considering printing the first Lisp book in South > Korea. We talked about 'Programming Clojure', 'ANSI Common Lisp', and > 'Practical Common Lisp'. I told him that I slightly prefered > 'Programming Clojure' to others because of Clojure's support for > concurrency and java interoperability. I said that the strong points > of Clojure would make programmers of main stream languages have > interests in Lisp. And he asked me questions like follows. > > 1. Has Clojure become stable? > He is afraid that the publishing of 'Programming Clojure' would be > meaningless if Clojure take significant changes after the publishing. > We know it will change. But the degree is the matter. > > 2. Could I get any benchmarking data about the performance of Clojure > and Java? > I read that Clojure can generate code as fast as Java in 'Programming > Clojure'. But he worries whether Clojure is slow like Groovy. Could I > get data about performance comparisons between Clojure and Java on > several algorithms? > > 3. Clojure can use Java libraries. Common Lisp can use C/C++ > libraries. Is it possible to say Clojure has strong points to Common > Lisp in the power of libraries? > > All these questions are not easy to answer for me. I think I should > give him the object information. So I hope that I get opinions from > the community. > > > > --~--~-~--~~~---~--~~ 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 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: Request for improved error reporting
On Apr 1, 10:43 am, hughw wrote: > On Mar 28, 8:24 pm, Stuart Sierra wrote: > [snip] > > > > > Also, if you're using SLIME, you lose line numbers every time you > > evaluate a form in the buffer. Type > > (require your.namespace :reload) at the REPL to get them back. > > This advice did not work for a situation I am encountering now and > encounter frequently. I did 'require with :reload, even :reload-all, > but I still have no idea what line in my source raised this exception. > A line number would be dang useful here :) > Oh... well now I see there is some useful info over in the stack crawl, in *inferior-lisp*. Hm. I retract my comment! Although I agree with the sentiment that improved error reporting would be great, I'm unsure exactly what I want. Thanks, Hugh --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
test-is now supports TAP
Not an April Fool's joke! New lib "clojure.contrib.test-is.tap" adds Test Anything Protocol (TAP) support to test-is. Use it like this: ;; (use 'clojure.contrib.test-is) ;; (use 'clojure.contrib.test-is.tap) ;; ;; (with-tap-output ;;(run-tests 'my.cool.library)) Warning: this doesn't work with clojure.contrib.test-clojure/run. I'm not sure why. I think it has something to do with how test-clojure/ run loads files. If anyone can shed some light on that, I'd appreciate it. Loading the files individually and calling (with-tap-output (run-all-tests)) works correctly. The idea for TAP output came from Meikel Brandmeyer's ClojureCheck library. -Stuart Sierra --~--~-~--~~~---~--~~ 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 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: Questions about Clojure and Common Lisp
On Wednesday 01 April 2009 16:51:49 Joshua Fox wrote: > > 3. Clojure can use Java libraries. Common Lisp can use C/C++ > > libraries. Is it possible to say Clojure has strong points to Common > > Lisp in the power of libraries? > > Accessing Java from Clojure is easier & more transparent than accessing C > from Common Lisp. And safe! You get an easily-debuggable exception instead of machine-level errors and silent corruption. And more efficient because your data is not crossing GC boundaries and possibly not even changing representation. -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e --~--~-~--~~~---~--~~ 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 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: Request for improved error reporting
On Apr 1, 10:53 am, hughw wrote: > I retract my comment! Although I agree with the sentiment that > improvederrorreportingwould be great, I'm unsure exactly what I > want. > Clarification: In the SLIME repl I invoke my function. It reports the error as java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.IFn (NO_SOURCE_FILE:0) I then invoke (.printStackTrace *e) at the repl. (I forgot to mention that earlier). Over in the *inferior lisp* window, it prints out a stack trace. At the root of the stack trace is the source file and line number faithfully reported. The behavior isn't much different if I invoke my function in the *inferior lisp* window in the first place. The short unhelpful message displays there, and I have to invoke .printStackTrace to get any useful information. I don't mind scrolling through the long stack crawl to discover where my error is. but I do wish the initial error report could somehow give me the information, rather thanrequiring the two step process (and switching windows when using the slime repl, although that is maybe not a clojure issue). Hugh --~--~-~--~~~---~--~~ 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 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: test-is now supports TAP
Hi Stuart, Stuart Sierra wrote: > Not an April Fool's joke! New lib "clojure.contrib.test-is.tap" adds > Test Anything Protocol (TAP) support to test-is. Use it like this: > > ;; (use 'clojure.contrib.test-is) > ;; (use 'clojure.contrib.test-is.tap) > ;; > ;; (with-tap-output > ;;(run-tests 'my.cool.library)) Cool :). > Warning: this doesn't work with clojure.contrib.test-clojure/run. I'm > not sure why. I think it has something to do with how test-clojure/ > run loads files. If anyone can shed some light on that, I'd > appreciate it. Loading the files individually and calling > (with-tap-output (run-all-tests)) > works correctly. I encountered the same problem when implementing JUnit-compatible XML output for test-is, and my guess (without having investigated thoroughly) is that it is indeed how test-clojure loads files. It pulls in the namespaces under test using: (apply require :reload-all namespaces) I guess that because test-is itself is included in these namespaces, your redefinitions of the reporting methods are lost. I worked around this myself for now by writing my own function to take a list of namespaces and run the tests in the way test-clojure does, allowing me to time the redefinitions to happen after the namespaces under test are pulled in. Out of interest, are you interested in other output formats for test-is? I chose JUnit compatible as a defacto-standard -- it integrates with the unofficial build server I have been working on as well as many other tools. I have it working but in need of some tweaks and cleanups. I am happy to donate the code (contributor agreement is in the mail to Rich) when I clean it up. It could also easily live outside of test-is as an optional extension, in which case I will probably make it public on GitHub. Cheers, Jason -- Pulse - Continuous Integration made easy. Does your project have a pulse? Try it free at: http://zutubi.com --~--~-~--~~~---~--~~ 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 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: A clojure server
On Wed, Apr 01, 2009 at 05:27:55PM +0200, Konrad Hinsen wrote: > I haven't tried Christian's Clojure-specific server yet, but if it > solves that problem, I'll probably adopt it. > Sadly it doesn't. I could experiment with a custom classloader, though. For testing, such a server doesn't help a lot, thats right. But I do my testing in emacs with slime anyway. What nailgun has (beside the way cooler name) is the ability to map *err* to stderr and *out* to stdout, which are just merged into one datastream in my code. OTOH, my code is written in Clojure, so it wins by default :P Christian --~--~-~--~~~---~--~~ 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 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: Request for improved error reporting
On Wed, Apr 1, 2009 at 9:10 AM, hughw wrote: > I don't mind scrolling through the long stack crawl to discover where > my error is. but I do wish the initial error report could somehow give > me the information, rather thanrequiring the two step process (and > switching windows when using the slime repl, although that is maybe > not a clojure issue). Also, in Slime, I've experimented with (use 'clojure.contrib.stacktrace) (use 'clojure.contrib.trace) and then typing (e) to see a shorter stack trace, because I do get frustrated by the long stack crawl. Unfortunately, about half of the time (e) doesn't show me any of the calls from *my code* that are part of the error, so I have to go back to the long stack anyway. I don't know what algorithm those libs use to cull the stack trace, but for me, they haven't been successful. So I still find this aspect of Clojure development unsatisfying. Also, yesterday, I got an error that a keyword couldn't be converted to a IFn. (Turned out I called one of my functions with a vector of keywords, rather than a vector of vectors of keywords, and inside the function, it was bombing trying to apply the keyword (which was supposed to be a vector) to something). If the error had actually showed me the keyword that couldn't be converted, I would have found the problem in two seconds. It ended up taking me a while to find the problem, mostly because the stack trace was so dang confusing I couldn't figure out what was calling the function with the wrong kind of input. Since static typing and compile-time checks are not present in Clojure, I think it's extra important to make sure it is easy to diagnose and fix these type mismatches. In other dynamic languages I've used, when I get a type mismatch, I usually find it very easy to identify and fix the source of the problem. A lot of it comes down to the quality of the stack trace, as well as making sure the error messages report as much as possible about the inputs/outputs that are causing the problem. --~--~-~--~~~---~--~~ 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 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 Users Group - Denmark
On Mar 31, 1:00 pm, martin_clausen wrote: > I would certainly be interested. Lau are you out there ? > > /mac > Ping! Yea I'm out here - My activity on the Google Group is very limited, but an assembly at JAOO with Rich igniting would definitely be interesting - I would consider arranging a trip for 1 or more of the developers at the company where I work. Keep me posted please, if this turns into something concrete /Lau --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
Full Clojure, Right Now! (tm)
Let's say I *hate* dealing with Java classpaths, especially within IDEs. Somehow, it's always the hardest configuration part of setting up a project. Let's add I want to use clojure + clojure.contrib. If my mileage is representative at all of most newcomer's experiences trying to get acquainted with clojure, this is very bad: all the following editors have a plugin for clojure, but none of them comes with an easy way to add clojure.contrib to the classpath. emacs+SLIME+clojure-mode - works incredibly great for core clojure netbeans - works great for core clojure intellij - works ok for core clojure; if I add contrib's jar to the libs, it seems to see it somehow, but still doesn't work I have spent ~30 mins in each one of them trying to make it work, and failed. I have also spent some time skimming different tutorials, and it looks like this is not covered. Would you fellow clojurians have wise advice for me? While I await your answers, I'm going to try eclipse. I think I've read Laurent Petit, the other day, saying his eclipse plugin automatically handles classpaths. I would *love* to know how to make it work in each one of these editors; I'm not yet decided on which one I want to use. --~--~-~--~~~---~--~~ 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 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: Request for improved error reporting
I have no experience with gradual typing, but I'd love to try it. It seems there are many situations where dynamic typing just makes things easier than in a language like Haskell, however I long for their ability to verify correctness at compile time. Vince On Mar 29, 10:49 am, André Thieme wrote: > On 29 Mrz., 01:55, Glen Stampoultzis wrote: > > > Hi, I've been really enjoying getting to know clojure. It's an awesome > > language that has got me very interested in learning more. One thing that > > hasn't left me impressed is the error reporting. > > [...] > > There are a few things wrong here and with clojure error reporting in > > general: > > > 1. I'm not getting a line number for some reason. > > 2. I don't get any indication what the nature of the error is. > > 3. I get a big (nested) stack trace that has more to do with clojure > > compiler internals than my program. > > I would like to make a comment that does not directly talk > about your specific issue, but about error reporting in > general. > I would love to hear more opinions about Gradual Typing for > Clojure. That would allow the compiler to catch errors before > the program is actually run. Your example that you gave at some > other point in this thread could have been caught during > compilation. > Please have a look at this > thread:http://groups.google.com/group/clojure/browse_thread/thread/7a48f48e4... --~--~-~--~~~---~--~~ 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 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: test-is now supports TAP
On Apr 1, 12:21 pm, Jason Sankey wrote: > Out of interest, are you interested in other output formats for test-is? > I chose JUnit compatible as a defacto-standard -- it integrates with > the unofficial build server I have been working on as well as many other > tools. I have it working but in need of some tweaks and cleanups. I am > happy to donate the code (contributor agreement is in the mail to Rich) > when I clean it up. It could also easily live outside of test-is as an > optional extension, in which case I will probably make it public on GitHub. Yes, I would like to have more output formats. I'd like to keep each format in a separate namespace (like I did with the TAP extension) but make them all available in clojure-contrib. Let me know if I can be of any help in integrating the JUnit output with test-is. -Stuart Sierra --~--~-~--~~~---~--~~ 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 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: Full Clojure, Right Now! (tm)
Hi, Am 01.04.2009 um 21:22 schrieb Daniel Jomphe: If my mileage is representative at all of most newcomer's experiences trying to get acquainted with clojure, this is very bad: all the following editors have a plugin for clojure, but none of them comes with an easy way to add clojure.contrib to the classpath. I use Vim with VimClojure. My setup looks like this: I have a directory where I put all jars I want in my classpath. Then I set the CLOJURE_EXT environment variable to this directory and startup the VC server. Et voilá. That's it. If I need a non-standard classpath I simply create a special directory, put my special jars there and point the CLOJURE_EXT env variable there instead of the usual directory. Yes. Environment variables work like binding. With this setup, I *never* *ever* had a problem. Adding a new jar file? No problem. Just drop it into the right directory. I don't see a way, how this could be further simplified. IMHO managing the Classpath is not the job of the editor. Sincerely Meikel smime.p7s Description: S/MIME cryptographic signature
Re: Clojure Users Group - Denmark
On Apr 1, 8:16 pm, Lau_of_DK wrote: > Keep me posted please, if this turns into something concrete Looks like we've got enough to get a user's group started -- great! Seems most people are in cph, and I am in Aarhus :-(, but that should be no problem. I know Rich was invited for JAOO at QCon London, but I don't know if he has confirmed yet (if you are following -- are you coming to Aarhus in september?). In either case, I'll make sure to arrange a small workshop or something of the like (I'm pretty sure the dcug will get a few new users at JAOO!). Please make sure you subscribe to the feed - I'll post news/updates there. Also, if you are arranging talks locally let me know, I'll put news up on the blog... Looking forward to it. Cheers, - Karl --~--~-~--~~~---~--~~ 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 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: Full Clojure, Right Now! (tm)
For one example of how to set up libraries so they can find each other, Stuart Halloway's *Programming Clojure* has a sample code bundle at http://www.pragprog.com/titles/shcloj/source_code. This is arranged in directories and includes scripts for executing the code. Clojure contrib is there among other libraries. Joshua On Wed, Apr 1, 2009 at 10:22 PM, Daniel Jomphe wrote: > > Let's say I *hate* dealing with Java classpaths, especially within > IDEs. > Somehow, it's always the hardest configuration part of setting up a > project. > > Let's add I want to use clojure + clojure.contrib. > > If my mileage is representative at all of most newcomer's experiences > trying to get acquainted with clojure, this is very bad: all the > following editors have a plugin for clojure, but none of them comes > with an easy way to add clojure.contrib to the classpath. > > emacs+SLIME+clojure-mode - works incredibly great for core clojure > netbeans - works great for core clojure > intellij - works ok for core clojure; if I add contrib's jar to the > libs, it seems to see it somehow, but still doesn't work > > I have spent ~30 mins in each one of them trying to make it work, and > failed. I have also spent some time skimming different tutorials, and > it looks like this is not covered. > > Would you fellow clojurians have wise advice for me? While I await > your answers, I'm going to try eclipse. I think I've read Laurent > Petit, the other day, saying his eclipse plugin automatically handles > classpaths. > > I would *love* to know how to make it work in each one of these > editors; I'm not yet decided on which one I want to use. > > > --~--~-~--~~~---~--~~ 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 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 Users Group - Denmark
On Wed, Apr 1, 2009 at 9:57 PM, Krukow wrote: > > > > On Apr 1, 8:16 pm, Lau_of_DK wrote: >> Keep me posted please, if this turns into something concrete > > Looks like we've got enough to get a user's group started -- great! > Seems most people are in cph, and I am in Aarhus :-(, but that should > be no problem. > > I know Rich was invited for JAOO at QCon London, but I don't know if > he has confirmed yet (if you are following -- are you coming to Aarhus > in september?). In either case, I'll make sure to arrange a small > workshop or something of the like (I'm pretty sure the dcug will get a > few new users at JAOO!). I was at JAOO Aarhus last year and just got the JAOO '09 announcement mail, so the process of bugging my employer to pay for the trip has officially begun :) > > Please make sure you subscribe to the feed - I'll post news/updates > there. Also, if you are arranging talks locally let me know, I'll put > news up on the blog... > > Looking forward to it. Cheers, > - Karl > > > -- Venlig hilsen / Kind regards, Christian Vest Hansen. --~--~-~--~~~---~--~~ 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 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: -> vs. comp
Thanks for the feedback everyone! Kev On Apr 1, 11:38 pm, Rayne wrote: > comp seems more appropriate here. > > On Mar 31, 11:52 pm, kkw wrote: > > > Hi folks, > > > I have some code where I wanted to: > > - take a list of stuff (which includes another list inside) > > - use 'seq-utils/flatten' to flatten the list > > - use 'interpose' to add comma-delimiting strings between the elements > > - print out the results, thereby creating comma-delimited output > > > I may choose between: > > > ((comp > > (fn [x] (apply println x)) > > (fn [x] (interpose ", " x)) > > seq-utils/flatten) > > mr) > > > OR > > > (-> mr > > seq-utils/flatten > > ((fn [x] (interpose ", " x))) > > ((fn [x] (apply println x > > > And I found the "->" notation marginally easier to interpret and > > understand. Apart from appearance, are there any benefits to using -> > > instead of the comp function? I happily concede that there exist nicer > > ways to achieve this goal, but the question I wanted to raise > > concerned the benefits of using -> vs comp or vice-versa. > > > Kev > > > Kev --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
lazy-xml/emit does not pad deeply
Hi, user=> (use 'clojure.contrib.lazy-xml) nil user=> (emit '{:tag :foo :attrs {:a "b" :c "d"} :content ({:tag :bar :attrs {:e "f"} :content ({:tag :baz :attrs nil :content ("hello")})})} :pad true) hello nil The 'foo' element is getting the requested padding, but it does not propagate to the nested elements. I believe line 150 of lazy-xml.clj should read, (apply emit-element c opts) to fix this. Regards, Phil --~--~-~--~~~---~--~~ 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 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: Request for improved error reporting
On Apr 1, 3:23 pm, Vincent Foley wrote: > I have no experience with gradual typing, but I'd love to try it. It > seems there are many situations where dynamic typing just makes things > easier than in a language like Haskell, however I long for their > ability to verify correctness at compile time. > > Vince > > On Mar 29, 10:49 am, André Thieme wrote: > > > On 29 Mrz., 01:55, Glen Stampoultzis wrote: > > > > Hi, I've been really enjoying getting to know clojure. It's an awesome > > > language that has got me very interested in learning more. One thing that > > > hasn't left me impressed is the error reporting. > > > [...] > > > There are a few things wrong here and with clojure error reporting in > > > general: > > > > 1. I'm not getting a line number for some reason. > > > 2. I don't get any indication what the nature of the error is. > > > 3. I get a big (nested) stack trace that has more to do with clojure > > > compiler internals than my program. > > > I would like to make a comment that does not directly talk > > about your specific issue, but about error reporting in > > general. > > I would love to hear more opinions about Gradual Typing for > > Clojure. That would allow the compiler to catch errors before > > the program is actually run. Your example that you gave at some > > other point in this thread could have been caught during > > compilation. > > Please have a look at this > > thread:http://groups.google.com/group/clojure/browse_thread/thread/7a48f48e4... I have seen that NullPointer before, especially when you use a proxy and don't have the import of the class defined. But on error reporting. Clojure is the best 'new' language I have seen that has good error reporting. It has really increased my productivity. For example, if there is an error at a line of clojure code, I can go to it (OK except for that particular one), that seems like a bug. But the majority of the time when I have a code error on my end, I kind of easily navigate to it. Can you say that in the common lisp world? I laugh at the premise. Good job on the error reporting in my opinion. --~--~-~--~~~---~--~~ 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 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 Users Group - Denmark
Hi, I'm currently in Copenhagen so I'm definitely interested. -Roland --~--~-~--~~~---~--~~ 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 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: Full Clojure, Right Now! (tm)
i ended up bagging all IDE's for now and did this: http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started up through "Installing Clojure.contrib." my hardest part was getting rlwrap to compile on my mac. my macports environment is all messed up so I had to do some hacking (and probably mess things up worse). On Wed, Apr 1, 2009 at 4:09 PM, Joshua Fox wrote: > For one example of how to set up libraries so they can find each > other, Stuart Halloway's *Programming Clojure* has a sample code bundle > at http://www.pragprog.com/titles/shcloj/source_code. This is arranged in > directories and includes scripts for executing the code. Clojure contrib is > there among > other libraries. > > Joshua > > On Wed, Apr 1, 2009 at 10:22 PM, Daniel Jomphe wrote: > >> >> Let's say I *hate* dealing with Java classpaths, especially within >> IDEs. >> Somehow, it's always the hardest configuration part of setting up a >> project. >> >> Let's add I want to use clojure + clojure.contrib. >> >> If my mileage is representative at all of most newcomer's experiences >> trying to get acquainted with clojure, this is very bad: all the >> following editors have a plugin for clojure, but none of them comes >> with an easy way to add clojure.contrib to the classpath. >> >> emacs+SLIME+clojure-mode - works incredibly great for core clojure >> netbeans - works great for core clojure >> intellij - works ok for core clojure; if I add contrib's jar to the >> libs, it seems to see it somehow, but still doesn't work >> >> I have spent ~30 mins in each one of them trying to make it work, and >> failed. I have also spent some time skimming different tutorials, and >> it looks like this is not covered. >> >> Would you fellow clojurians have wise advice for me? While I await >> your answers, I'm going to try eclipse. I think I've read Laurent >> Petit, the other day, saying his eclipse plugin automatically handles >> classpaths. >> >> I would *love* to know how to make it work in each one of these >> editors; I'm not yet decided on which one I want to use. >> >> > > > > --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
I feel I'm making an elementary mistake with proxy, but I don't know what...
Isn't this supposed to work? (defn create-layout [] (proxy [java.awt.LayoutManager] [] (addLayoutComponent [name comp] (println "Called addLayoutComponent")) (removeLayoutComponent [comp] (println "Called removeLayoutComponent")) (preferredLayoutSize [container] (println "Called preferredLayoutSize")) (minimumLayoutSize [container] (println "Called minimumLayoutSize")) (layoutContainer [container] (println "Called layoutContainer" user> (def layout (create-layout)) #'user/layout user> (instance? java.awt.LayoutManager layout) true user> (. layout preferredLayoutSize) ; Evaluation aborted. java.lang.IllegalArgumentException: No matching field found: preferredLayoutSize for class clojure.proxy.java.lang.Object$LayoutManager (NO_SOURCE_FILE:0) [Thrown class clojure.lang.Compiler$CompilerException] I get the same thing for all its methods, when I try to call them manually and also when I hook it up to a Swing container. I'd greatly appreciate it if anyone has any insight regarding what is going on... Thanks, -Luke --~--~-~--~~~---~--~~ 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 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: I feel I'm making an elementary mistake with proxy, but I don't know what...
Ugh, I hate it when I make a fool of myself and realize the answer to a question 1 minute after posting it, even when wrestling with it for an hour beforehand... The reason the example doesn't work is that the method is of a different arity than the one I'm attempting to call. Still doesn't explain why it's failing with the same error when I try to actually use it on a Swing object, but I'll try to isolate that condition separately... Sorry for the pointless post. Thanks, -Luke On Apr 1, 8:29 pm, levand wrote: > Isn't this supposed to work? > > (defn create-layout [] > (proxy [java.awt.LayoutManager] [] > (addLayoutComponent [name comp] > (println "Called addLayoutComponent")) > (removeLayoutComponent [comp] > (println "Called removeLayoutComponent")) > (preferredLayoutSize [container] > (println "Called preferredLayoutSize")) > (minimumLayoutSize [container] > (println "Called minimumLayoutSize")) > (layoutContainer [container] > (println "Called layoutContainer" > > user> (def layout (create-layout)) > #'user/layout > user> (instance? java.awt.LayoutManager layout) > true > user> (. layout preferredLayoutSize) > ; Evaluation aborted. java.lang.IllegalArgumentException: No matching > field found: preferredLayoutSize for class > clojure.proxy.java.lang.Object$LayoutManager (NO_SOURCE_FILE:0) > [Thrown class clojure.lang.Compiler$CompilerException] > > I get the same thing for all its methods, when I try to call them > manually and also when I hook it up to a Swing container. > > I'd greatly appreciate it if anyone has any insight regarding what is > going on... > > Thanks, > -Luke --~--~-~--~~~---~--~~ 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 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: Full Clojure, Right Now! (tm)
has the Clojure Box type of thing appeared for non-Windows systems? (googling says no.) --~--~-~--~~~---~--~~ 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 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: Full Clojure, Right Now! (tm)
Emacs built with the emacs-starter-kit from http://github.com/technomancy/emacs-starter-kit/tree/master gets both clojure and clojure.contrib set up correctly. To use other jars, I had to hack the emacs-starter-kit stuff slightly; it seems that swank-clojure by default adds all jars in "~/.clojure" to the classpath, but then clojure-mode.el overwrites that with it's own classpath: (setq swank-clojure-jar-path (concat clojure-src-root "/clojure/clojure.jar") swank-clojure-extra-classpaths (list (concat clojure-src-root "/clojure-contrib/src/" I wasn't sure how to merge the two nicely so I just replaced the above with: (setq swank-clojure-jar-path (concat clojure-src-root "/clojure/clojure.jar") swank-clojure-extra-classpaths (append (directory-files "~/.clojure" t ".jar$") (list (concat clojure-src-root "/clojure-contrib/src/") Once that's done, I can put any jars I like in ~/.clojure and they get added to the classpath when I re-start slime. - Korny On Thu, Apr 2, 2009 at 6:22 AM, Daniel Jomphe wrote: > > Let's say I *hate* dealing with Java classpaths, especially within > IDEs. > Somehow, it's always the hardest configuration part of setting up a > project. > > Let's add I want to use clojure + clojure.contrib. > > If my mileage is representative at all of most newcomer's experiences > trying to get acquainted with clojure, this is very bad: all the > following editors have a plugin for clojure, but none of them comes > with an easy way to add clojure.contrib to the classpath. > > emacs+SLIME+clojure-mode - works incredibly great for core clojure > netbeans - works great for core clojure > intellij - works ok for core clojure; if I add contrib's jar to the > libs, it seems to see it somehow, but still doesn't work > > I have spent ~30 mins in each one of them trying to make it work, and > failed. I have also spent some time skimming different tutorials, and > it looks like this is not covered. > > Would you fellow clojurians have wise advice for me? While I await > your answers, I'm going to try eclipse. I think I've read Laurent > Petit, the other day, saying his eclipse plugin automatically handles > classpaths. > > I would *love* to know how to make it work in each one of these > editors; I'm not yet decided on which one I want to use. > > > -- Kornelis Sietsma korny at my surname dot com "Every jumbled pile of person has a thinking part that wonders what the part that isn't thinking isn't thinking of" --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
Find the function you need
While still learning clojure, I often times need a function and am not sure if it already exists or where to look for it. I thought it would be useful to be able to give a return value and arguments and search all functions for ones which return the given value when called with the given arguments. Here's what I came up with: (defn test-for "Tests to see if a given function called with given arguments results in given value, catching any exceptions that occur" [v f & args] (try (= v (apply f args)) (catch Exception e nil))) (defn find-func "Given a value and arguments, searches all public functions in all namespaces" [v & args] (map key (mapcat (fn [ns_] (filter #(binding [*out* nil *in* nil] (apply test-for v (val %) args)) (ns-publics (the-ns ns_ (all-ns Binding *in* and *out* stops any IO functions from messing up the search. There's probably still ways this could be dangerous though, depending on the given args. Hope someone finds this useful or improves upon it. -Mitch --~--~-~--~~~---~--~~ 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 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: basic question on structuring refs
Thanks. I think the problem was I was assuming somehow I could keep track of my individual structures by some sort of object reference, independent of their position in the world - woolly object-oriented thinking - which was confusing me. If I instead have a key (or query function) that finds a structure in the world, then I can use option (c) in my original post - I'll have a ref for the world, then @world will be a map of key to refs to my actual structures - (def world (ref {})) (defn do_something_to [key something] (dosync (let [struct_ref (@world key)] (if struct_ref (alter struct_ref something) If I understand correctly, two threads calling do_something_to with different keys won't collide, as they read @world but don't change it. I'll get a collision if one thread changes @world and another changes an individual structure - but I guess that's necessary, as the change might have deleted the record with the key needed by the other thread. I'm definitely finding this easier if I think of it in terms of storing stuff in a database :) - Korny On Wed, Apr 1, 2009 at 10:58 PM, Rich Hickey wrote: > > > > On Apr 1, 5:46 am, Christophe Grand wrote: > > Hello Korny, > > > > I share your questioning. > > > > On 1 avr, 06:57, Korny Sietsma wrote: > > > > > (A) one ref for the whole world - in which case how do I stop parallel > > > changes to two unrelated structures in the world from causing > transaction > > > retries? > > > > In this case, I wonder whether to extend "ensure" so as to be able to > > ensure an invariant over a ref would be a good idea. > > eg: > > > > (ensure world f arg1 arg2) ; compute (f @world arg1 arg2) > > ; > > (commute world g arg3 arg4) ; commute iff (f @world arg1 arg2) still > > returns the same value. > > > > Interesting - I'll think about it. Off the top of my head I'm > concerned about the use of commute - it's not really commute if you > need to ensure that something hasn't changed. Also, there will be a > lot of pressure on the root, and need for history, even if the > mechanism avoids retries. You would only consider this if the need to > see the world as a single value dominated other concerns. > > Until then, I recommend option C. Korny really has two things here - > the set (please, anything but list) of identities that constitutes the > world, and those identities themselves. > > Rich > > > > -- Kornelis Sietsma korny at my surname dot com "Every jumbled pile of person has a thinking part that wonders what the part that isn't thinking isn't thinking of" --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
speed question
I've been playing around with rendering a mandelbrot set, and using pure java it renders about 2 seconds on my machine, however it runs about 10 times as slow in clojure, I was curious if I'm doing anything obviously wrong, or if it's just life :) I do run it with the -server flag, which does improve it a bit. I've got the java and clojure source below: import java.awt.Canvas; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.image.BufferStrategy; import java.awt.image.ImageObserver; import javax.swing.JFrame; import javax.swing.JPanel; public class Mandelbrot extends Canvas implements ImageObserver { public static final int WIDTH = 640; public static final int HEIGHT = 640; private static int BAILOUT = 4; private static int MAX_ITERATIONS = 32; public BufferStrategy strategy; public Mandelbrot () { setBounds(0,0,WIDTH,HEIGHT); setBackground(Color.BLACK); JPanel panel = new JPanel(); panel.setPreferredSize(new Dimension(WIDTH, HEIGHT)); panel.setLayout(null); panel.add(this); JFrame frame = new JFrame("Mandelbrot"); frame.add(panel); frame.setBounds(0,0,WIDTH, HEIGHT); frame.setResizable(false); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //create a double buffer createBufferStrategy(2); strategy = getBufferStrategy(); requestFocus(); } private int checkBounds(float x, float y) { float cr = x; float ci = y; float zi = 0.0f; float zr = 0.0f; int i = 0; while (true) { i++; float temp = zr * zi; float zr2 = zr * zr; float zi2 = zi * zi; zr = zr2 - zi2 + cr; zi = temp + temp + ci; if (zi2 + zr2 > BAILOUT) return i; if (i > MAX_ITERATIONS) return 0; } } private void draw() { float x = -2.1f, y = -1.5f, z = 3.0f; int i, j; Graphics g = strategy.getDrawGraphics(); g.clearRect(0, 0, getWidth(), getHeight()); for (i = 0; i < HEIGHT; i++) { for (j = 0; j < WIDTH; j++) { int value = checkBounds((x + z*(i/(float)WIDTH)), (y + z*(j/(float) HEIGHT))); if (value > 0) { g.setColor(new Color(value*255/MAX_ITERATIONS)); g.drawRect(i, j, 0, 0); } } strategy.show(); } strategy.show(); } public static void main(String args[]) { Mandelbrot m = new Mandelbrot(); long startTime = System.currentTimeMillis(); m.draw(); System.out.println((System.currentTimeMillis() - startTime)/1000); } } Clojure: (ns main (:import (java.awt Color Container Graphics Canvas Dimension) (javax.swing JPanel JFrame) (java.awt.image BufferedImage BufferStrategy))) (def *width* 640) (def *height* 640) (def *max-steps* 32) (defn on-thread [f] (doto (new Thread f) (.start))) (defn check-bounds [x y] (loop [px x py y zx 0.0 zy 0.0 zx2 0.0 zy2 0.0 value 0] (if (and (< value *max-steps*) (< (+ zx2 zy2) 4.0)) (let [new-zy (+ (* 2.0 zx zy) py) new-zx (+ (- zx2 zy2) px) new-zx2 (* new-zx new-zx) new-zy2 (* new-zy new-zy)] (recur px py new-zx new-zy new-zx2 new-zy2 (inc value))) (if (== value *max-steps*) 0 value (defn draw-line [g y] (let [dy (- 1.25 (* 2.5 (/ y *height*)))] (doseq [x (range 0 *width*)] (let [dx (- (* 2.5 (/ x *width*)) 2.0)] (let [value (check-bounds dx dy)] (if (> value 0) (doto g (. setColor (Color. (* value (/ 255 *max- steps* (. drawRect x y 0 0 (defn draw-lines ([buffer g] (draw-lines buffer g *height*)) ([buffer g y] (doseq [y (range 0 y)] (draw-line g y) ;(on-thread (draw-line g y)) (. buffer show (defn draw [canvas] (let [buffer (. canvas getBufferStrategy) g(. buffer getDrawGra
Re: Setting up Clojure on OS X
Good stuff - but I'm surprised you link to Phil Hagelberg's port of clojure-mode, but not to his emacs-starter-kit: http://github.com/technomancy/emacs-starter-kit/tree/master If you are going down the emacs path, but don't already have your own emacs setup, I highly recommend the starter kit - it (mostly) just works, and it'll do all the git fetching and the like for you. - Korny On Tue, Mar 31, 2009 at 1:26 AM, Telman Yusupov wrote: > > I have similar series posts, hopefully they might be useful to you: > > http://yusupov.com/blog/2009/basic-clojure-setup-part-1/ - Basic > environment/Java setup somewhat tailored towards OS X > > http://yusupov.com/blog/2009/basic-clojure-setup-part-2/ - Setting up > Emacs/Slime > > http://yusupov.com/blog/2009/basic-clojure-setup-part-3/ - Keeping up- > to-date > > Cheers, > > Telman > > > On Mar 30, 8:59 am, Sean wrote: > > Mark, > > This is a great writeup on installing clojure. As an OSX nerd, my > > main problem is getting an editor up and running. Maybe you could add > > a section on setting up an editor? I know the wiki was a good place > > to start. > > > > On Mar 30, 7:02 am, Mark Reid wrote: > > > > > Hi, > > > > > I've just written a blog post describing how I set up Clojure on my > > > Mac: > > > > >http://mark.reid.name/sap/setting-up-clojure.html > > > > > My main aims were to make it easy to configure the classpath for > > > various projects while still having a single Clojure command I can run > > > from anywhere to open a interactive session or run a script. Hopefully > > > others might find this useful as well. > > > > > Feedback is appreciated as I am new to Clojure and acutely aware that > > > I may not be doing things in the most elegant way. > > > > > Mark > > > --http://mark.reid.name > > > > > > > -- Kornelis Sietsma korny at my surname dot com "Every jumbled pile of person has a thinking part that wonders what the part that isn't thinking isn't thinking of" --~--~-~--~~~---~--~~ 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 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: speed question
>From a quick glance, I think the lack of type hints is what's slowing down your Clojure code. You can set the global variable *warn-on-reflection* to true, to get a sense of where to add your type hints. -Patrick --~--~-~--~~~---~--~~ 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 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: bound?
On Mar 26, 6:24 pm, mikel wrote: > How would you write bound? (defmacro bound? [nm & [the-ns]] `(let [nm-nsname# (namespace '~nm) the-ns# (if nm-nsname# (find-ns (symbol nm-nsname#)) (or ~the-ns ~clojure.core/*ns*)) nm# (symbol (name '~nm))] (if (contains? (ns-map the-ns#) nm#) (if (var? (get (ns-map the-ns#) nm#)) (.isBound (get (ns-map the-ns#) nm#)) false) false))) Thanks to Stephen Gilardi for the suggestions. --~--~-~--~~~---~--~~ 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 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: speed question
I actually tried forcing the type hints and didn't really see a noticeable improvement, just made the code hard to read for the most part. On Apr 1, 9:57 pm, CuppoJava wrote: > From a quick glance, I think the lack of type hints is what's slowing > down your Clojure code. > You can set the global variable *warn-on-reflection* to true, to get a > sense of where to add your type hints. > -Patrick --~--~-~--~~~---~--~~ 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 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: speed question
On Apr 1, 9:40 pm, Dmitri wrote: > I've been playing around with rendering a mandelbrot set, and using > pure java it renders about 2 seconds on my machine, however it runs > about 10 times as slow in clojure, I was curious if I'm doing anything > obviously wrong, or if it's just life :) I do run it with the -server > flag, which does improve it a bit. I've got the java and clojure > source below: Are you running the Clojure source as a script on the command line? Some of the delay may be Clojure starting up and parsing the script. You should also try using primitive types in the loops. See this thread for details: http://groups.google.com/group/clojure/browse_thread/thread/61f236e830d98cb3/9637bba3451a30bd -Stuart Sierra --~--~-~--~~~---~--~~ 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 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: speed question
I'm running it as a script with: java -server -cp clojure.jar clojure.lang.Script mandelbrot.clj as I mentioned earlier, I did try forcing all the primitives, but didn't notice much of a difference, I did try running the draw method repeatedly to make sure it wasn't just the startup times causing it to run slow. as a note I also tried a jython version and it runs about twice as fast for me, which I think is comparable, and it could just mean that there is a hit on performance over java that only so much can be done about. I'm mostly curious if I made any newbie mistakes that would cause it to perform a lot worse than it should. I do expect pure java to run faster in the end. On Apr 1, 10:49 pm, Stuart Sierra wrote: > On Apr 1, 9:40 pm, Dmitri wrote: > > > I've been playing around with rendering a mandelbrot set, and using > > pure java it renders about 2 seconds on my machine, however it runs > > about 10 times as slow in clojure, I was curious if I'm doing anything > > obviously wrong, or if it's just life :) I do run it with the -server > > flag, which does improve it a bit. I've got the java and clojure > > source below: > > Are you running the Clojure source as a script on the command line? > Some of the delay may be Clojure starting up and parsing the script. > > You should also try using primitive types in the loops. See this > thread for > details:http://groups.google.com/group/clojure/browse_thread/thread/61f236e83... > > -Stuart Sierra --~--~-~--~~~---~--~~ 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 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: Questions about Clojure and Common Lisp
I have used Java and Jsp for many years as the platform for my business offerings. All new development is now being done in Clojure - I am comfortable (nay, delighted) with it's stability and viability. On Wed, Apr 1, 2009 at 6:12 PM, Jon Harrop wrote: > > On Wednesday 01 April 2009 16:51:49 Joshua Fox wrote: >> > 3. Clojure can use Java libraries. Common Lisp can use C/C++ >> > libraries. Is it possible to say Clojure has strong points to Common >> > Lisp in the power of libraries? >> >> Accessing Java from Clojure is easier & more transparent than accessing C >> from Common Lisp. > > And safe! You get an easily-debuggable exception instead of machine-level > errors and silent corruption. > > And more efficient because your data is not crossing GC boundaries and > possibly not even changing representation. > > -- > Dr Jon Harrop, Flying Frog Consultancy Ltd. > http://www.ffconsultancy.com/?e > > > > --~--~-~--~~~---~--~~ 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 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: speed question
I'm running it as a script with: java -server -cp clojure.jar clojure.lang.Script mandelbrot.clj as I mentioned earlier, I did try forcing all the primitives, but didn't notice much of a difference, I also did try running the draw function repeatedly to make sure it wasn't just the startup times causing it to run slow. (main [] ... (time (draw canvas)) (time (draw canvas)) (time (draw canvas as a note I also tried a jython version and it runs about twice as fast for me, which I think is comparable, and it could just mean that there is a hit on performance over java that only so much can be done about. I'm mostly curious if I made any newbie mistakes that would cause it to perform a lot worse than it should. I do expect pure java to run faster in the end. On Apr 1, 10:49 pm, Stuart Sierra wrote: > On Apr 1, 9:40 pm, Dmitri wrote: > > > I've been playing around with rendering a mandelbrot set, and using > > pure java it renders about 2 seconds on my machine, however it runs > > about 10 times as slow in clojure, I was curious if I'm doing anything > > obviously wrong, or if it's just life :) I do run it with the -server > > flag, which does improve it a bit. I've got the java and clojure > > source below: > > Are you running the Clojure source as a script on the command line? > Some of the delay may be Clojure starting up and parsing the script. > > You should also try using primitive types in the loops. See this > thread for > details:http://groups.google.com/group/clojure/browse_thread/thread/61f236e83... > > -Stuart Sierra --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
Ironicly Maven2 is the lightest I could come up with
...for easy dependency management and no-compile project setup. https://github.com/dysinger/clojure-pom/tree Using maven only for the dependency management and to create a custom repl script allows me to still use emacs/slime for dynamic development of clojure code. My motivation is 3 fold: 1) I have lots of small modules and want convention over configuration (no boiler plate ant scripts or other such cut and paste) 2) I want access to the kabazillion libraries in the maven repos - just go look at mvnrepository.com for example. 3) Although I spent 10 years on Java, I am a dynamic language fan. I don't care or want to AOT compile at the moment. I just want to setup the libraries that my clojure code depends on and start writing / prototyping clojure code in Emacs SLIME. I would love to hear some feedback and/or what other people have been working on. -Tim --~--~-~--~~~---~--~~ 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 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: Ironicly Maven2 is the lightest I could come up with
Dogh! Plz pardon my spelling. :D (embarrassed) On Apr 1, 7:25 pm, dysinger wrote: > ...for easy dependency management and no-compile project > setup.https://github.com/dysinger/clojure-pom/tree > > Using maven only for the dependency management and to create a custom > repl script allows me to still use emacs/slime for dynamic development > of clojure code. > > My motivation is 3 fold: > > 1) I have lots of small modules and want convention over configuration > (no boiler plate ant scripts or other such cut and paste) > > 2) I want access to the kabazillion libraries in the maven repos - > just go look at mvnrepository.com for example. > > 3) Although I spent 10 years on Java, I am a dynamic language fan. I > don't care or want to AOT compile at the moment. I just want to setup > the libraries that my clojure code depends on and start writing / > prototyping clojure code in Emacs SLIME. > > I would love to hear some feedback and/or what other people have been > working on. > > -Tim --~--~-~--~~~---~--~~ 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 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: speed question
I did this: (defn draw [#^Canvas canvas] (let [#^BufferStrategy buffer (. canvas getBufferStrategy) #^Graphics g (. buffer getDrawGraphics)] (doseq [y (range 0 *height*)] (let [dy (- 1.5 (* 2.5 (/ y *height*)))] (doseq [x (range 0 *width*)] (let [dx (- (* 3 (/ x *width*)) 2.1) value (check-bounds dx dy)] (when (> value 0) (.setColor g (Color. (* value (/ 255 *max-steps* (.drawRect g x y 0 0 (.show buffer))) (.show buffer))) and this: (defn check-bounds [x y] (let [px (float x) py (float y)] (loop [zx (float 0.0) zy (float 0.0) zx2 (float 0.0) zy2 (float 0.0) value (int 0)] (if (and (< value *max-steps*) (< (+ zx2 zy2) 4.0)) (let [new-zy (float (+ (* 2.0 zx zy) py)) new-zx (float (+ (- zx2 zy2) px)) new-zx2 (float (* new-zx new-zx)) new-zy2 (float (* new-zy new-zy))] (recur new-zx new-zy new-zx2 new-zy2 (inc value))) (if (== value *max-steps*) 0 value) and it seemed to speed up notably. On Apr 1, 11:18 pm, Dmitri wrote: > I'm running it as a script with: > java -server -cp clojure.jar clojure.lang.Script mandelbrot.clj > > as I mentioned earlier, I did try forcing all the primitives, but > didn't notice much of a difference, I also did try running the draw > function repeatedly to make sure it wasn't just the startup times > causing it to run slow. > > (main [] > ... > > (time (draw canvas)) > (time (draw canvas)) > (time (draw canvas > > as a note I also tried a jython version and it runs about twice as > fast for me, which I think is comparable, and it could just mean that > there is a > hit on performance over java that only so much can be done about. > > I'm mostly curious if I made any newbie mistakes that would cause it > to perform a lot worse than it should. I do expect pure java to run > faster in the end. > > On Apr 1, 10:49 pm, Stuart Sierra wrote: > > > On Apr 1, 9:40 pm, Dmitri wrote: > > > > I've been playing around with rendering a mandelbrot set, and using > > > pure java it renders about 2 seconds on my machine, however it runs > > > about 10 times as slow in clojure, I was curious if I'm doing anything > > > obviously wrong, or if it's just life :) I do run it with the -server > > > flag, which does improve it a bit. I've got the java and clojure > > > source below: > > > Are you running the Clojure source as a script on the command line? > > Some of the delay may be Clojure starting up and parsing the script. > > > You should also try using primitive types in the loops. See this > > thread for > > details:http://groups.google.com/group/clojure/browse_thread/thread/61f236e83... > > > -Stuart Sierra --~--~-~--~~~---~--~~ 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 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: Ironicly Maven2 is the lightest I could come up with
On Apr 2, 12:27 am, dysinger wrote: > Dogh! Plz pardon my spelling. :D (embarrassed) > > On Apr 1, 7:25 pm, dysinger wrote: > > > > > ...for easy dependency management and no-compile project > > setup.https://github.com/dysinger/clojure-pom/tree > > > Using maven only for the dependency management and to create a custom > > repl script allows me to still use emacs/slime for dynamic development > > of clojure code. > > > My motivation is 3 fold: > > > 1) I have lots of small modules and want convention over configuration > > (no boiler plate ant scripts or other such cut and paste) > > > 2) I want access to the kabazillion libraries in the maven repos - > > just go look at mvnrepository.com for example. > > > 3) Although I spent 10 years on Java, I am a dynamic language fan. I > > don't care or want to AOT compile at the moment. I just want to setup > > the libraries that my clojure code depends on and start writing / > > prototyping clojure code in Emacs SLIME. > > > I would love to hear some feedback and/or what other people have been > > working on. > > > -Tim Personally, I check Clojure and clojure-contrib out of their repos, use ant to build them, and use an ultra-simple shell script to start a Clojure repl in an environment where the classpath contains references to all the library jars I use. The script reads the jars at startup time, so all I have to do to add some new library is drop it into the right directory (well, I then need to restart Clojure, or manually add the newly-added jar to Clojure's classpath). My "IDE" is good ol' Gnu Emacs with SLIME. That's it, basically. For loading projects I use a dirt-simple system loader I knocked together. --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---