Anyone want to start a Clojure study group in San Francisco Bay Area?
I'm really excited about clojure, and would like to study it with like minded individuals. Any takers? I can probably find a place to meet. Thanks, ~Jason --~--~-~--~~~---~--~~ 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: Anyone want to start a Clojure study group in San Francisco Bay Area?
Jason, Check out: http://www.meetup.com/The-Bay-Area-Clojure-User-Group/calendar/9719627/?a=ce1p_grp The next meeting is March 12th. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
conj questions
When working on a list, both cons and conj add to the front. In my tests, cons is considerably faster than conj. I'm trying to figure out why. Here's the implementation of conj. (def #^{:arglists '([coll x] [coll x xs]) :doc conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type.} conj (fn conj ([coll x] (. clojure.lang.RT (conj coll x))) ([coll x xs] (if xs (recur (conj coll x) (first xs) (next xs)) (conj coll x) The line for the parameter list [coll x] seems to call itself recursively with the exact same arguments. How does that ever terminate? -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~~---~--~~ 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: conj questions
On Fri, Mar 6, 2009 at 7:55 AM, Mark Volkmann r.mark.volkm...@gmail.com wrote: When working on a list, both cons and conj add to the front. In my tests, cons is considerably faster than conj. I'm trying to figure out why. In my testing they are the same speed. Here's the implementation of conj. (def #^{:arglists '([coll x] [coll x xs]) :doc conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type.} conj (fn conj ([coll x] (. clojure.lang.RT (conj coll x))) ([coll x xs] (if xs (recur (conj coll x) (first xs) (next xs)) (conj coll x) The line for the parameter list [coll x] seems to call itself recursively with the exact same arguments. How does that ever terminate? You're probably getting confused by the old-style Java interop syntax. (. clojure.lang.RT (conj coll x)) is the same as: (clojure.lang.RT/conj coll x) --Chouser --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Proposal: remove auto-load of user.clj
Currently, user.clj is loaded automatically during Clojure boot (in RT static init). I think this is done as a convenience for repl usage, since other apps could easily include a 'load' 'require' or 'use' of whatever is needed. I am proposing that auto-loading of user.clj be removed. A command line option for loading user.clj could be added for repl usage. The motivation for this change is that user.clj may contain defmethods for print-method or other multifns that are undesirable for certain applications (defmethod in one namespace can change a multifn in another namespace regardless of use or require specs). I know I can avoid the problem by either not having a user.clj, or not having defmethods in user.clj, but it seems more straightforward to have a command-line option rather than have such restrictions. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
What is Clojure NOT good for?
Is it fair to say that Clojure shines in algorithmic processing, string processing, concurrency management, but that there are better choices in other areas: - Application programming , where the key challenge is fitting a standard three-tier application to the business domain. - Enterprise programming, where the challenge is gluing together overweight and fragile libraries, and one should always use exactly the set of software which the API creators envisioned? Rich himself has suggested something along these lines, but I wonder what others think. Joshua --~--~-~--~~~---~--~~ 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: conj questions
On Fri, Mar 6, 2009 at 7:00 AM, Chouser chou...@gmail.com wrote: On Fri, Mar 6, 2009 at 7:55 AM, Mark Volkmann r.mark.volkm...@gmail.com wrote: When working on a list, both cons and conj add to the front. In my tests, cons is considerably faster than conj. I'm trying to figure out why. In my testing they are the same speed. Here's my code that seems to show that cons is faster than conj for both lists and vectors. Am I doing something suspect that is skewing my results? (def size 1) (defn build-coll prints the time required to change the contents of a collection to the result of a given function n times where values from 0 to n-1 are passed to the function [coll a-fn size] (let [an-atom (atom coll)] (time (dotimes [i size] (reset! an-atom (a-fn @an-atom i ;(println @an-atom) )) (println \nconj list) ; Adds to front. (build-coll '() (fn [coll i] (conj coll i)) size) (println \ncons list) ; Adds to front. (build-coll '() (fn [coll i] (cons i coll)) size) (println \nconj vector) ; Adds to back. (build-coll [] (fn [coll i] (conj coll i)) size) (println \ncons vector) ; Adds to front. (build-coll [] (fn [coll i] (cons i coll)) size) Here's the implementation of conj. (def #^{:arglists '([coll x] [coll x xs]) :doc conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type.} conj (fn conj ([coll x] (. clojure.lang.RT (conj coll x))) ([coll x xs] (if xs (recur (conj coll x) (first xs) (next xs)) (conj coll x) The line for the parameter list [coll x] seems to call itself recursively with the exact same arguments. How does that ever terminate? You're probably getting confused by the old-style Java interop syntax. (. clojure.lang.RT (conj coll x)) is the same as: (clojure.lang.RT/conj coll x) Ah ... you're right! I haven't looked at the old style in a while. It seems weird that it can break apart (conj coll x) to get what you show above before evaluating it. I much prefer the new style. -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~~---~--~~ 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: Monad tutorial, part 1
On Mar 5, 2009, at 19:21, Konrad Hinsen wrote: For those who are interested in monads but don't want to learn Haskell first to understand the Haskell-based monad tutorials, I have started to write a Clojure monad tutorial. Part 1 is now available: Part 2 is now published as well: http://onclojure.com/2009/03/06/a-monad-tutorial-for-clojure- programmers-part-2/ You will have to more patient for part 3, as it isn't written yet! 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: Proposal: remove auto-load of user.clj
How about removing it from the RT static init and into the REPL function? Paul On 3/6/09, MikeM michael.messini...@invista.com wrote: Currently, user.clj is loaded automatically during Clojure boot (in RT static init). I think this is done as a convenience for repl usage, since other apps could easily include a 'load' 'require' or 'use' of whatever is needed. I am proposing that auto-loading of user.clj be removed. A command line option for loading user.clj could be added for repl usage. The motivation for this change is that user.clj may contain defmethods for print-method or other multifns that are undesirable for certain applications (defmethod in one namespace can change a multifn in another namespace regardless of use or require specs). I know I can avoid the problem by either not having a user.clj, or not having defmethods in user.clj, but it seems more straightforward to have a command-line option rather than have such restrictions. --~--~-~--~~~---~--~~ 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: Proposal: remove auto-load of user.clj
How about removing it from the RT static init and into the REPL function? I think that would work and it would be transparent for repl users. A command line option to not load user.clj might be nice to have in this 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: Comparing lists
On Mar 6, 12:19 am, Mark Engelberg mark.engelb...@gmail.com wrote: I know that this has been brought up several times here, but I don't recall whether there was ever any resolution: It seems reasonable to expect (compare '(1 2 3) '(4 5)) to do a lexicographic comparison of the two lists, just like (compare [1 2 3] [4 5]) does. Is there an intentional reason why compare doesn't work on lists (or sequences in general), or has it simply not yet been implemented? It just hasn't yet been implemented. 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 -~--~~~~--~~--~--~---
Clojure infinite loop
Hi, Having attend Stu Halloway's talk on Clojure, at NFJS, I decided to download it and check it out. The language seems like a perfect fit for some database set manipulation that I do, and may need to do in the future. So, I downloaded clojure and started it up with the command: java -cp clojure.jar clojure.lang.Repl The docs indicate: This will bring up a simple read-eval-print loop (REPL). Is this truly an infinite loop? I tried a number of commands to exit. So, I just hit ctrl-C. (This is on Windows). Anyhow, one other question, since clojure can access Java classes, I should be able to open a database connection and do all of the good DB things, right? Thanks for your patience, Mike --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
float vs fraction (just playing around)
I thought it neat that clojure supports fractions (just like Smalltalk). user= (/ 3) 1/3 I was sort of surprised by this. user= (+ (float (* (/ 2) (/ 3))) (float (* (/ 2) (/ 3))) ) 0.3334 (= (+ (float (* (/ 2) (/ 3))) (float (* (/ 2) (/ 3))) ) (/ 3) ) yields true How is tracking these number internally? And, why does it present the float version of 1/3, as rounded up? --~--~-~--~~~---~--~~ 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: conj questions
Hi Mr Volkmann, Here are my result: user= (println \nconj list) conj list nil user= ; Adds to front. user= (build-coll '() (fn [coll i] (conj coll i)) size) Elapsed time: 28.09443 msecs nil user= user= (println \ncons list) cons list nil user= ; Adds to front. user= (build-coll '() (fn [coll i] (cons i coll)) size) Elapsed time: 9.616097 msecs nil user= user= (println \nconj vector) conj vector nil user= ; Adds to back. user= (build-coll [] (fn [coll i] (conj coll i)) size) Elapsed time: 30.66506 msecs nil user= user= (println \ncons vector) cons vector nil user= ; Adds to front. user= (build-coll [] (fn [coll i] (cons i coll)) size) Elapsed time: 13.421022 msecs nil user= (println \nconj list) conj list nil user= ; Adds to front. user= (build-coll '() (fn [coll i] (conj coll i)) size) Elapsed time: 12.922417 msecs nil user= user= (println \ncons list) cons list nil user= ; Adds to front. user= (build-coll '() (fn [coll i] (cons i coll)) size) Elapsed time: 5.386954 msecs nil user= user= (println \nconj vector) conj vector nil user= ; Adds to back. user= (build-coll [] (fn [coll i] (conj coll i)) size) Elapsed time: 21.946047 msecs nil user= user= (println \ncons vector) cons vector nil user= ; Adds to front. user= (build-coll [] (fn [coll i] (cons i coll)) size) Elapsed time: 5.002202 msecs nil user= (println \nconj list) conj list nil user= ; Adds to front. user= (build-coll '() (fn [coll i] (conj coll i)) size) Elapsed time: 4.008019 msecs nil user= user= (println \ncons list) cons list nil user= ; Adds to front. user= (build-coll '() (fn [coll i] (cons i coll)) size) Elapsed time: 4.179548 msecs nil user= user= (println \nconj vector) conj vector nil user= ; Adds to back. user= (build-coll [] (fn [coll i] (conj coll i)) size) Elapsed time: 4.926285 msecs nil user= user= (println \ncons vector) cons vector nil user= ; Adds to front. user= (build-coll [] (fn [coll i] (cons i coll)) size) Elapsed time: 3.94195 msecs nil user= (println \nconj list) conj list nil user= ; Adds to front. user= (build-coll '() (fn [coll i] (conj coll i)) size) Elapsed time: 5.206835 msecs nil user= user= (println \ncons list) cons list nil user= ; Adds to front. user= (build-coll '() (fn [coll i] (cons i coll)) size) Elapsed time: 3.958223 msecs nil user= user= (println \nconj vector) conj vector nil user= ; Adds to back. user= (build-coll [] (fn [coll i] (conj coll i)) size) Elapsed time: 6.29202 msecs nil user= user= (println \ncons vector) cons vector nil user= ; Adds to front. user= (build-coll [] (fn [coll i] (cons i coll)) size) Elapsed time: 4.560739 msecs nil user= (println \nconj list) conj list nil user= ; Adds to front. user= (build-coll '() (fn [coll i] (conj coll i)) size) Elapsed time: 14.811261 msecs nil user= user= (println \ncons list) cons list nil user= ; Adds to front. user= (build-coll '() (fn [coll i] (cons i coll)) size) Elapsed time: 13.438472 msecs nil user= user= (println \nconj vector) conj vector nil user= ; Adds to back. user= (build-coll [] (fn [coll i] (conj coll i)) size) Elapsed time: 17.98685 msecs nil user= user= (println \ncons vector) cons vector nil user= ; Adds to front. user= (build-coll [] (fn [coll i] (cons i coll)) size) Elapsed time: 13.808419 msecs nil user= On my computer, cons is faster for the first runs but after warm up results are more similar. Even some conj tests are a little bit faster. At the same time, thank you very much for your nice tutorial. Stéphane Rousseau On Mar 6, 8:15 am, Mark Volkmann r.mark.volkm...@gmail.com wrote: On Fri, Mar 6, 2009 at 7:00 AM, Chouser chou...@gmail.com wrote: On Fri, Mar 6, 2009 at 7:55 AM, Mark Volkmann r.mark.volkm...@gmail.com wrote: When working on a list, both cons and conj add to the front. In my tests, cons is considerably faster than conj. I'm trying to figure out why. In my testing they are the same speed. Here's my code that seems to show that cons is faster than conj for both lists and vectors. Am I doing something suspect that is skewing my results? (def size 1) (defn build-coll prints the time required to change the contents of a collection to the result of a given function n times where values from 0 to n-1 are passed to the function [coll a-fn size] (let [an-atom (atom coll)] (time (dotimes [i size] (reset! an-atom (a-fn @an-atom i ;(println @an-atom) )) (println \nconj list) ; Adds to front. (build-coll '() (fn [coll i] (conj coll i)) size) (println \ncons list) ; Adds to front. (build-coll '() (fn [coll i] (cons i coll)) size) (println \nconj vector) ; Adds to back. (build-coll [] (fn [coll i] (conj coll i)) size) (println \ncons vector) ; Adds to front. (build-coll [] (fn [coll i] (cons i coll)) size) Here's the implementation of conj. (def #^{:arglists '([coll x] [coll x xs]) :doc conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The
Re: What is Clojure NOT good for?
On Mar 6, 8:15 am, Joshua Fox joshuat...@gmail.com wrote: Is it fair to say that Clojure shines in algorithmic processing, string processing, concurrency management, but that there are better choices in other areas: - Application programming , where the key challenge is fitting a standard three-tier application to the business domain. - Enterprise programming, where the challenge is gluing together overweight and fragile libraries, and one should always use exactly the set of software which the API creators envisioned? Rich himself has suggested something along these lines, but I wonder what others think. I don't recall suggesting that. I would certainly consider application programming a prime domain for Clojure. OTOH, if that's the definition of enterprise programming, I'm not sure any language is going to produce a satisfying result. Being a Lisp, and having the ability to generate primitive math ops that map to machine instructions, Clojure can scale high and low. I wouldn't count it out in many domains just yet, as we're just starting to see it applied to a wide array of problems. Often its applicability will just be a matter of libraries and macro packages. I think it is unlikely to end up with less applicability than Java. Even what seems like a categoric absence, like static typing, may be filled with a la carte typing and constraint systems built on logic programming extensions like the Datalog work. Of course, I'm biased, but wide applicability is certainly the intent of Clojure. I'm interested in what others think as well. 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 -~--~~~~--~~--~--~---
Confused about vars, symbols, names,...
I would like to have a function which tells me about the values of a var, where the parameter to the function is a string equal to the 'name' of the var. For example: (defn checkNil [name] If the var with the given (String) name is nil, display a message; result = value of var. (when (nil? (value of the var called name)) (display (str name is nil))) (value of the var called name)) so that (def x nil) (checkNil x) should display: x is nil -- (display s) being a function that shows the string s somewhere. The question is, how do I express (value of the var called name)? I tried this: (var (symbol name)) but that caused the exception: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol Is this possible? Another way to do it would be as follows. (defn checkNil [x] If the variable x is nil, display a message; result = value of x. (when (nil? x) (display (str (name of the var x) ) is nil))) x) so that (def x nil) (checkNil x) should display: x is nil. In this case - how to do: (name of the var x)? --~--~-~--~~~---~--~~ 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: Proposal: remove auto-load of user.clj
On Mar 6, 2009, at 8:08 AM, MikeM wrote: I know I can avoid the problem by either not having a user.clj, or not having defmethods in user.clj, but it seems more straightforward to have a command-line option rather than have such restrictions. Every launch of Clojure has the opportunity to specify a classpath to use. Since user.clj is loaded from classpath, it seems to me that's a sufficient mechanism to avoid loading a given user.clj for a given launch of Clojure. I think the convenience of the user.clj hook file being auto-loaded very early in launch is significant. I'm in favor of keeping it as-is. --Steve smime.p7s Description: S/MIME cryptographic signature
Re: Clojure infinite loop
On Fri, Mar 6, 2009 at 12:24 AM, mike.farn...@gmail.com mike.farn...@gmail.com wrote: Hi, Having attend Stu Halloway's talk on Clojure, at NFJS, I decided to download it and check it out. The language seems like a perfect fit for some database set manipulation that I do, and may need to do in the future. Hi, Mike, and welcome! So, I downloaded clojure and started it up with the command: java -cp clojure.jar clojure.lang.Repl The docs indicate: This will bring up a simple read-eval-print loop (REPL). Is this truly an infinite loop? I tried a number of commands to exit. So, I just hit ctrl-C. (This is on Windows). I had the same question in getting started. Someone told me to type (System/exit 0) which will call the java.lang.System.exit method and terminate the program. This seems to work for me. Anyhow, one other question, since clojure can access Java classes, I should be able to open a database connection and do all of the good DB things, right? You can find the details here: http://clojure.org/java_interop Thanks for your patience, Mike --~--~-~--~~~---~--~~ 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 infinite loop
On Fri, Mar 6, 2009 at 12:24 AM, mike.farn...@gmail.com mike.farn...@gmail.com wrote: So, I downloaded clojure and started it up with the command: java -cp clojure.jar clojure.lang.Repl The docs indicate: This will bring up a simple read-eval-print loop (REPL). Is this truly an infinite loop? I tried a number of commands to exit. So, I just hit ctrl-C. (This is on Windows). You can also stop it by typing (System/exit 0). Anyhow, one other question, since clojure can access Java classes, I should be able to open a database connection and do all of the good DB things, right? Sure. Here's an example of some Java interop: http://clojure.org/jvm_hosted. There's a Clojure interface to jdbc in the clojure-contrib project: http://code.google.com/p/clojure-contrib/source/browse/trunk/src/clojure/contrib/sql.clj . Shawn --~--~-~--~~~---~--~~ 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 infinite loop
On Thu, Mar 5, 2009 at 11:24 PM, mike.farn...@gmail.com mike.farn...@gmail.com wrote: Hi, Having attend Stu Halloway's talk on Clojure, at NFJS, I decided to download it and check it out. The language seems like a perfect fit for some database set manipulation that I do, and may need to do in the future. So, I downloaded clojure and started it up with the command: java -cp clojure.jar clojure.lang.Repl The docs indicate: This will bring up a simple read-eval-print loop (REPL). Is this truly an infinite loop? I tried a number of commands to exit. So, I just hit ctrl-C. (This is on Windows). ctrl-c is the right way to exit under Windows. Under UNIX, Linux and Mac OS X, I think ctrl-d is preferred. Anyhow, one other question, since clojure can access Java classes, I should be able to open a database connection and do all of the good DB things, right? Right. See http://www.ociweb.com/mark/clojure/article.html#Databases. -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~~---~--~~ 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: Confused about vars, symbols, names,...
Hi! I tried this: (var (symbol name)) but that caused the exception: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol var is a special form. If var was a function, (symbol name) would have been evaluated and the result would have been passed to var as an argument. Special Forms and macros don't necessarily work that way - it's up to them to decide how to treat the arguments. You can use ns-resolve to find a var by name: user= (def x 1) #'user/x ; find the var. *ns* is bound to the current namespace user= (ns-resolve *ns* (symbol x)) #'user/x ; get the value user= (deref (ns-resolve *ns* (symbol x))) 1 :shorter way of deref'ing user= @(ns-resolve *ns* (symbol x)) 1 clojure.core/ns-resolve ([ns sym]) Returns the var or Class to which a symbol will be resolved in the namespace, else nil. Note that if the symbol is fully qualified, the var/Class to which it resolves need not be present in the namespace. Hope this helps. Kind regards, achim Am 06.03.2009 um 15:23 schrieb timc: I would like to have a function which tells me about the values of a var, where the parameter to the function is a string equal to the 'name' of the var. For example: (defn checkNil [name] If the var with the given (String) name is nil, display a message; result = value of var. (when (nil? (value of the var called name)) (display (str name is nil))) (value of the var called name)) so that (def x nil) (checkNil x) should display: x is nil -- (display s) being a function that shows the string s somewhere. The question is, how do I express (value of the var called name)? I tried this: (var (symbol name)) but that caused the exception: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol Is this possible? Another way to do it would be as follows. (defn checkNil [x] If the variable x is nil, display a message; result = value of x. (when (nil? x) (display (str (name of the var x) ) is nil))) x) so that (def x nil) (checkNil x) should display: x is nil. In this case - how to do: (name of the var x)? --~--~-~--~~~---~--~~ 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 infinite loop
On Fri, Mar 6, 2009 at 9:27 AM, Paul Stadig p...@stadig.name wrote: On Fri, Mar 6, 2009 at 12:24 AM, mike.farn...@gmail.com I tried a number of commands to exit. So, I just hit ctrl-C. (This is on Windows). I had the same question in getting started. Someone told me to type (System/exit 0) which will call the java.lang.System.exit method and terminate the program. This seems to work for me. On windows, Ctrl-Z Enter works as well. This is the normal end-of-file pattern on Windows. That's Ctrl and Z together, then released, then the Enter key. --Chouser --~--~-~--~~~---~--~~ 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 infinite loop
On Mar 6, 2009, at 9:44 AM, Mark Volkmann wrote: ctrl-c is the right way to exit under Windows. Under UNIX, Linux and Mac OS X, I think ctrl-d is preferred. I agree. Here's some more info: On the Unixes, ctl-d represents end-of-file (end of input stream). Usually terminals and terminal-like interfaces will send ctl-d immediately to the process waiting for input even in cases where input would normally be line-buffered before being sent. ctl-d works to quit the repl immediately on Linux and Mac OS X. On Windows the corresponding end-of-file marker is ctl-z. However in a default cmd window ctl-z doesn't act immediately. Instead, it's interpreted after pressing return. Both ctl-z return and ctl-c work to quit the clojure Repl on Windows. As the latter is more succinct, I think it's reasonable for it to be preferred. (System/exit 0) also works on all platforms. Having something like: (defn quit [] (System/exit 0)) in your user.clj would also allow you to quit with (user/quit) or just (quit) if the current namespace is user. --Steve smime.p7s Description: S/MIME cryptographic signature
Re: What is Clojure NOT good for?
Application programming is exactly what we do with Clojure, we are not using it in a bubble, it's there to implement all the complex logic we need. We use over 130 jars (Spring,...) and we use them from both Clojure and some Java components. We are replacing with Clojure code the Java high level components inherited from our product V1.0. Enterprise programming is restricted to Java APIs however we share data between Java, Clojure and Ruby transparently through YAML and messaging. Cobol/Fortran does not support maps as far as I can remember so adding Cobol/Fortran components in our product would be a challenge :)) If Clojure was another better LISP without any access to Java that would restrict its utility severely. To us it would not had any sex appeal at all without Java access. It was a major factor in our decision to use Clojure even V1.0 is not finalized yet an go live with it. We needed a fast delivery approach and Clojure allowed us to reuse Java components with minimal changes while allowing us to code complex logic much more faster in Clojure. For us Clojure = less useless code lines = fast delivery = less test headaches = major success : Luc On Mar 6, 8:15 am, Joshua Fox joshuat...@gmail.com wrote: Is it fair to say that Clojure shines in algorithmic processing, string processing, concurrency management, but that there are better choices in other areas: - Application programming , where the key challenge is fitting a standard three-tier application to the business domain. - Enterprise programming, where the challenge is gluing together overweight and fragile libraries, and one should always use exactly the set of software which the API creators envisioned? Rich himself has suggested something along these lines, but I wonder what others think. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Workflow poll?
As my Clojure application is now getting quite complex, I was curious as to what workflow people are using for design, development, testing and debugging. I'll get started with what I've found, so far, though I am definitely open to suggestion. There are a few parts I'm not quite satisfied with. I use Emacs+Slime in windows (I'd prefer a Mac if I could afford one) as my primary development environment. I start Emacs with a project- specific batch file that adds all the libraries I use to the CLASSPATH environment variable and then invokes Emacs, so all I have to do to add a new library to the project is to dump it in the lib folder in my project, and add a line in the bat file. For high-level design, I usually just spend time thinking about it and jot down my ideas in a physical notebook. When I have a decent idea of where I'm going, I start banging out code - usually I do my mid- and low-level design as I code. Typically I just do the first thing that comes to mind that will work, and then refactor wherever I see an opportunity for improvement. I find that this works better than trying to do more detailed planning up front - no matter how much time I spent, there was always some variable or use case that escaped me and I'd end up making significant changes anyway. It also really tends to keep code size to a minimum. I try to write each expression in the REPL, first, to make sure it works, though this is becoming less and less necessary as I get more confident with Clojure. Currently I am in an effort to put my existing code, except for the UI portions, under complete test coverage using the test-is library. To keep things clean, I am putting all the tests for each file in a separate file. This is actually my first experience with unit tests. The motivator for it is a problem I am still struggling with - my time spent debugging is increasing exponentially relative to the amount of code I have. Hopefully unit tests, in conjunction with writing smaller, more atomic functions will allow me to have more confidence in individual functions which will ease the debugging process. Debugging itself is probably my biggest headache, and I think it's really the only point where Clojure's lack of maturity presents a real problem. When I encounter unexpected results, I typically follow this pattern: 1. If there is a stack trace, inspect it to see if it tells me the problem (usually it doesn't - it really only helps for syntax errors) 2. Inspect the code to make sure its nothing obvious. 3. Use the REPL to construct a data structure like the one in question, and pass it to the function that seems to be the problem (This can be a real PITA with a more complex structure - in my case, more often than not, it's a zip of an xml file. 4. Decompose the data structure and function from step 3 into their component expressions and apply them, one by one, until I find one that doesn't work. 5. Loop back to step 3, only one function further down the call stack, until I find the problem. 6. If I'm desperate or the problem is heavily recursive and too complicated to use the procedure above, I add trace statements. I hate doing this, though, since it requires adding lots of ugly (do (println...) ...) blocks and juggling s-expressions. This can take hours even for an extremely simple bug, if it's buried deeply enough. I have tried using JSwat - in some cases it can be of help, but I can't get it to work smoothly and reliably. If just inspecting a variable helps to solve the problem, then it's a help, but I can't make it reliably step through and inspect at each step of the way. Sometimes, it also will refuse to hit a breakpoint, for no apparent reason. My dream debugger would be to pause execution on a certain line, be able to step through function calls, and have a REPL with all local vars available so I could explore the problem. But I'm pretty sure that doesn't exist. Anyway, that's my process, and my frustrations. How do you all do it? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Missing function?
Hi, in the API specs on http://clojure.org/api#toc247 I see the function frest. However, when I build Clojure (Checked out revision 1326 from Googlecode) this function seems to be missing. Any idea? Regards, Arie --~--~-~--~~~---~--~~ 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: Workflow poll?
My dream debugger would be to pause execution on a certain line, be able to step through function calls, and have a REPL with all local vars available so I could explore the problem. But I'm pretty sure that doesn't exist. My dream debugger would be this: http://www.lambdacs.com/debugger/ but for clojure. In a nutshell, it instruments your java program and record everything it does. So you don't have to pause, you can step forward or backward through the execution, search, etc. It's a great way to deal with mutability too because if for instance, you use random values then they would be different every time you run your program and some might cause crashes and others not. However, if you recorded their values and the bug they caused, then it can't get away. --~--~-~--~~~---~--~~ 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: What is Clojure NOT good for?
The biggest barrier to using Clojure in an enterprise environment is that enterprise projects are typically built and maintained by 100s of replaceable code-monkeys and consultants, all of which understand Java and almost none of which understand Lisp of any kind, let alone Clojure. To be honest, even if I could get away with it, I wouldn't want to inflict hell on the next person who has to fix something in my Clojure code. Even if they're a good developer, they are very unlikely to care about Clojure or functional programming. I heard of one guy in our company who wrote some web services in Scala on the grounds that they were one-off services that wouldn't need to be modified - until they were, and everyone was roundly cursing him for it. They were small enough that it turned out to be easier to redo them in Java rather than to learn Scala and understand his code. Like it or not, enterprise development = Java or .NET until the language landscape has some radical changes. On Mar 6, 9:22 am, Rich Hickey richhic...@gmail.com wrote: On Mar 6, 8:15 am, Joshua Fox joshuat...@gmail.com wrote: Is it fair to say that Clojure shines in algorithmic processing, string processing, concurrency management, but that there are better choices in other areas: - Application programming , where the key challenge is fitting a standard three-tier application to the business domain. - Enterprise programming, where the challenge is gluing together overweight and fragile libraries, and one should always use exactly the set of software which the API creators envisioned? Rich himself has suggested something along these lines, but I wonder what others think. I don't recall suggesting that. I would certainly consider application programming a prime domain for Clojure. OTOH, if that's the definition of enterprise programming, I'm not sure any language is going to produce a satisfying result. Being a Lisp, and having the ability to generate primitive math ops that map to machine instructions, Clojure can scale high and low. I wouldn't count it out in many domains just yet, as we're just starting to see it applied to a wide array of problems. Often its applicability will just be a matter of libraries and macro packages. I think it is unlikely to end up with less applicability than Java. Even what seems like a categoric absence, like static typing, may be filled with a la carte typing and constraint systems built on logic programming extensions like the Datalog work. Of course, I'm biased, but wide applicability is certainly the intent of Clojure. I'm interested in what others think as well. 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: Missing function?
On Fri, Mar 6, 2009 at 10:42 AM, hotcore xapw...@gmail.com wrote: in the API specs on http://clojure.org/api#toc247 I see the function frest. However, when I build Clojure (Checked out revision 1326 from Googlecode) this function seems to be missing. The website generally documents the latest release, not the latest SVN HEAD (with a few exceptions). You're probably looking for 'fnext': user= (doc fnext) - clojure.core/fnext ([x]) Same as (first (next x)) nil --Chouser --~--~-~--~~~---~--~~ 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: Missing function?
Which raises the question when will there be another release? The current one is getting pretty wildly outdated. Also, I think a corresponding release of contrib would be a good idea. People just trying out Clojure are unlikely to want to mess with the nightly builds, but all the libraries are built against that. I think it is time for a refresh. On Fri, Mar 6, 2009 at 10:52 AM, Chouser chou...@gmail.com wrote: On Fri, Mar 6, 2009 at 10:42 AM, hotcore xapw...@gmail.com wrote: in the API specs on http://clojure.org/api#toc247 I see the function frest. However, when I build Clojure (Checked out revision 1326 from Googlecode) this function seems to be missing. The website generally documents the latest release, not the latest SVN HEAD (with a few exceptions). You're probably looking for 'fnext': user= (doc fnext) - clojure.core/fnext ([x]) Same as (first (next x)) nil --Chouser --~--~-~--~~~---~--~~ 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: What is Clojure NOT good for?
I agree about consultants (these days it's not anymore an synonym for expert) and the state of the market but... If you write a new software product and you are concerned with deadlines and speed in general, Java is not the way to go anymore considering the pile of code you need to do anything significant these days. More code = more people = inefficiencies. I know some business where HR and IT managers come back with this mantra that they can find Java and .Net coders, anything else is too risky or too scarce on the market. It reminds the time when you could not get fired when buying IBM mainframes. Many HR departments do not understand anything about software development in general and the profile of individuals needed. They go for the standard available bodies with a single fit all projects skill set and their batteries of psychological tests. That explains a lot why productivity is low on most projects. The landscape will change when HR changes (and managers)... seeking intelligence and initiative instead of a single static fit. (looks like StarTrek quest...) The day they will understand that software development is not a Taylor assembly line (less the efficiency), the situation will improve. You cannot get more from people that what you are asking for... I am not generally optimistic about the state of things in the software industry but we need to bring in tools that are more accessible to the masses. Clojure is one if you compared it to CL... Luc The biggest barrier to using Clojure in an enterprise environment is that enterprise projects are typically built and maintained by 100s of replaceable code-monkeys and consultants, all of which understand Java and almost none of which understand Lisp of any kind, let alone Clojure. To be honest, even if I could get away with it, I wouldn't want to inflict hell on the next person who has to fix something in my Clojure code. Even if they're a good developer, they are very unlikely to care about Clojure or functional programming. I heard of one guy in our company who wrote some web services in Scala on the grounds that they were one-off services that wouldn't need to be modified - until they were, and everyone was roundly cursing him for it. They were small enough that it turned out to be easier to redo them in Java rather than to learn Scala and understand his code. Like it or not, enterprise development = Java or .NET until the language landscape has some radical changes. --~--~-~--~~~---~--~~ 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: What is Clojure NOT good for?
If these theories are correct (and I believe they are) then this is an opportunity to beat the crap out these guys in head-to-head competition. The Rails guys seem to have successfully broken into industry by being better (relatively compared to Java/VB/C#). We can do the same thing if we don't wait for others to do it instead. (I know this sounds like a PG essay, but it is true.) On Fri, Mar 6, 2009 at 11:07 AM, lprefonta...@softaddicts.ca wrote: I agree about consultants (these days it's not anymore an synonym for expert) and the state of the market but... If you write a new software product and you are concerned with deadlines and speed in general, Java is not the way to go anymore considering the pile of code you need to do anything significant these days. More code = more people = inefficiencies. I know some business where HR and IT managers come back with this mantra that they can find Java and .Net coders, anything else is too risky or too scarce on the market. It reminds the time when you could not get fired when buying IBM mainframes. Many HR departments do not understand anything about software development in general and the profile of individuals needed. They go for the standard available bodies with a single fit all projects skill set and their batteries of psychological tests. That explains a lot why productivity is low on most projects. The landscape will change when HR changes (and managers)... seeking intelligence and initiative instead of a single static fit. (looks like StarTrek quest...) The day they will understand that software development is not a Taylor assembly line (less the efficiency), the situation will improve. You cannot get more from people that what you are asking for... I am not generally optimistic about the state of things in the software industry but we need to bring in tools that are more accessible to the masses. Clojure is one if you compared it to CL... Luc The biggest barrier to using Clojure in an enterprise environment is that enterprise projects are typically built and maintained by 100s of replaceable code-monkeys and consultants, all of which understand Java and almost none of which understand Lisp of any kind, let alone Clojure. To be honest, even if I could get away with it, I wouldn't want to inflict hell on the next person who has to fix something in my Clojure code. Even if they're a good developer, they are very unlikely to care about Clojure or functional programming. I heard of one guy in our company who wrote some web services in Scala on the grounds that they were one-off services that wouldn't need to be modified - until they were, and everyone was roundly cursing him for it. They were small enough that it turned out to be easier to redo them in Java rather than to learn Scala and understand his code. Like it or not, enterprise development = Java or .NET until the language landscape has some radical changes. --~--~-~--~~~---~--~~ 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: What is Clojure NOT good for?
On Mar 6, 7:46 am, Luke VanderHart luke.vanderh...@gmail.com wrote: The biggest barrier to using Clojure in an enterprise environment is that enterprise projects are typically built and maintained by 100s of replaceable code-monkeys and consultants, all of which understand Java and almost none of which understand Lisp of any kind, let alone Clojure. That's why Clojure has JVM interoperability ;-P Think of Clojure as an embedded higher-level language running within Java. You can hide it completely with a Java wrapper so that nobody has to read or write Clojure code but the local Clojure expert(s). We do this all the time with C and Fortran: we only require our libraries' users to know C or Fortran, but we embed Lua and ANSI Common Lisp (via ECL) in our libraries to do harder coding tasks, and use other scripting languages to generate code. All those other languages are hidden from the users. A well-written library treats other programmers on the team as users who don't have to know the internals of the library. mfh --~--~-~--~~~---~--~~ 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: Workflow poll?
If it works with Java, then it should be possible to get it working with Clojure, no? It may take some work, but should be possible. I have to say, my experience with JSwat was adequate. Obviously a debugger that could step back would be better, but with JSwat I was able to step between Java code and Clojure code. This was indispensable. There's no way I could have gotten as far as I have with Terracotta without it. There are obvious places for improvement. As you mentioned, putting a breakpoint in clojure code, JSwat doesn't always catch it. I suspect this has something to do with macro expansions, but I'm just shooting from the hip here. Paul On Fri, Mar 6, 2009 at 10:46 AM, Dan redalas...@gmail.com wrote: My dream debugger would be to pause execution on a certain line, be able to step through function calls, and have a REPL with all local vars available so I could explore the problem. But I'm pretty sure that doesn't exist. My dream debugger would be this: http://www.lambdacs.com/debugger/ but for clojure. In a nutshell, it instruments your java program and record everything it does. So you don't have to pause, you can step forward or backward through the execution, search, etc. It's a great way to deal with mutability too because if for instance, you use random values then they would be different every time you run your program and some might cause crashes and others not. However, if you recorded their values and the bug they caused, then it can't get away. --~--~-~--~~~---~--~~ 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: float vs fraction (just playing around)
On Mar 5, 10:00 pm, mike.farn...@gmail.com mike.farn...@gmail.com wrote: I was sort of surprised by this. user= (+ (float (* (/ 2) (/ 3))) (float (* (/ 2) (/ 3))) ) 0.3334 (= (+ (float (* (/ 2) (/ 3))) (float (* (/ 2) (/ 3))) ) (/ 3) ) yields true How is tracking these number internally? And, why does it present the float version of 1/3, as rounded up? This is a question about floating-point arithmetic, not about Clojure. See http://en.wikipedia.org/wiki/IEEE_754 and http://docs.sun.com/source/806-3568/ncg_goldberg.html In particular, note that Java uses binary representation for floating- point numbers, which probably explains the rounding up observation. mfh --~--~-~--~~~---~--~~ 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: What is Clojure NOT good for?
On Mar 6, 2009, at 14:15, Joshua Fox wrote: Is it fair to say that Clojure shines in algorithmic processing, string processing, concurrency management, but that there are better choices in other areas: I'd say that Clojure is probably suited for anything that the JVM is suited for. Its Lisp nature makes it much more flexible than ordinary languages, and there seem to be few limits to what it can do with the JVM, considering that it is even possible to generate low- level maths primitives. As for what JVM languages are not good for in general, there is the obvious domain of systems-level programming, and there are other domains such as number crunching, where there is a severe lack of good libraries in the Java world. Real-time programming tasks may also be difficult, considering that garbage collection can introduce a delay at any time, but I am not really competent to talk about this. 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: What is Clojure NOT good for?
Oh, I agree with you 100%. I outlined why I wouldn't use Clojure in a project self-described as enterprise, but at risk of ranting I didn't get into how I consider the word enterprise synonymous with bloated, bureaucracy-bound, over-engineered, unoriginal and above all /expensive/ ball of tar. Ironically, enterprise has nothing to do with actual size or significance of the project. I've seen very small projects that are infected with enterprise, whereas I don't think there is anything enterprisy about, say, Google. -Luke On Mar 6, 11:07 am, lprefonta...@softaddicts.ca wrote: I agree about consultants (these days it's not anymore an synonym for expert) and the state of the market but... If you write a new software product and you are concerned with deadlines and speed in general, Java is not the way to go anymore considering the pile of code you need to do anything significant these days. More code = more people = inefficiencies. I know some business where HR and IT managers come back with this mantra that they can find Java and .Net coders, anything else is too risky or too scarce on the market. It reminds the time when you could not get fired when buying IBM mainframes. Many HR departments do not understand anything about software development in general and the profile of individuals needed. They go for the standard available bodies with a single fit all projects skill set and their batteries of psychological tests. That explains a lot why productivity is low on most projects. The landscape will change when HR changes (and managers)... seeking intelligence and initiative instead of a single static fit. (looks like StarTrek quest...) The day they will understand that software development is not a Taylor assembly line (less the efficiency), the situation will improve. You cannot get more from people that what you are asking for... I am not generally optimistic about the state of things in the software industry but we need to bring in tools that are more accessible to the masses. Clojure is one if you compared it to CL... Luc The biggest barrier to using Clojure in an enterprise environment is that enterprise projects are typically built and maintained by 100s of replaceable code-monkeys and consultants, all of which understand Java and almost none of which understand Lisp of any kind, let alone Clojure. To be honest, even if I could get away with it, I wouldn't want to inflict hell on the next person who has to fix something in my Clojure code. Even if they're a good developer, they are very unlikely to care about Clojure or functional programming. I heard of one guy in our company who wrote some web services in Scala on the grounds that they were one-off services that wouldn't need to be modified - until they were, and everyone was roundly cursing him for it. They were small enough that it turned out to be easier to redo them in Java rather than to learn Scala and understand his code. Like it or not, enterprise development = Java or .NET until the language landscape has some radical changes. --~--~-~--~~~---~--~~ 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: What is Clojure NOT good for?
My wife and I both write software. She think's I'm insane to use Clojure because the poor sucker who has to maintain what I've written will be uncomfortable with anything other than Java. (She may also think the poor sucker won't want to deal with my dubious programming skills, but that's another story.) Sometimes it takes a killer app to kick-start a technology's popularity. Other times, a new technology establishes its beachhead in an area that no one cares about and then migrates into more glamorous and mission-critical places. I think a beachhead for Clojure could be automated testing for Java code. Having spent a few years writing automated tests, I don't believe Java is the best language for testing Java applications. That may sound bizarre or unintuitive, and I was skeptical the first time someone suggested the idea to me, but Java's syntactic constraints can make it cumbersome to write test code. Bill On Mar 6, 10:07 am, lprefonta...@softaddicts.ca wrote: I agree about consultants (these days it's not anymore an synonym for expert) and the state of the market but... If you write a new software product and you are concerned with deadlines and speed in general, Java is not the way to go anymore considering the pile of code you need to do anything significant these days. More code = more people = inefficiencies. I know some business where HR and IT managers come back with this mantra that they can find Java and .Net coders, anything else is too risky or too scarce on the market. It reminds the time when you could not get fired when buying IBM mainframes. Many HR departments do not understand anything about software development in general and the profile of individuals needed. They go for the standard available bodies with a single fit all projects skill set and their batteries of psychological tests. That explains a lot why productivity is low on most projects. The landscape will change when HR changes (and managers)... seeking intelligence and initiative instead of a single static fit. (looks like StarTrek quest...) The day they will understand that software development is not a Taylor assembly line (less the efficiency), the situation will improve. You cannot get more from people that what you are asking for... I am not generally optimistic about the state of things in the software industry but we need to bring in tools that are more accessible to the masses. Clojure is one if you compared it to CL... Luc The biggest barrier to using Clojure in an enterprise environment is that enterprise projects are typically built and maintained by 100s of replaceable code-monkeys and consultants, all of which understand Java and almost none of which understand Lisp of any kind, let alone Clojure. To be honest, even if I could get away with it, I wouldn't want to inflict hell on the next person who has to fix something in my Clojure code. Even if they're a good developer, they are very unlikely to care about Clojure or functional programming. I heard of one guy in our company who wrote some web services in Scala on the grounds that they were one-off services that wouldn't need to be modified - until they were, and everyone was roundly cursing him for it. They were small enough that it turned out to be easier to redo them in Java rather than to learn Scala and understand his code. Like it or not, enterprise development = Java or .NET until the language landscape has some radical changes. --~--~-~--~~~---~--~~ 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: Missing function?
Hi, which means that frest is in fact obsolete and fnext is it's successor? Tia, Arie 2009/3/6 Chouser chou...@gmail.com On Fri, Mar 6, 2009 at 10:42 AM, hotcore xapw...@gmail.com wrote: in the API specs on http://clojure.org/api#toc247 I see the function frest. However, when I build Clojure (Checked out revision 1326 from Googlecode) this function seems to be missing. The website generally documents the latest release, not the latest SVN HEAD (with a few exceptions). You're probably looking for 'fnext': user= (doc fnext) - clojure.core/fnext ([x]) Same as (first (next x)) nil --Chouser --~--~-~--~~~---~--~~ 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: What is Clojure NOT good for?
Usually if has mustaches, 4 legs, oval shaped eyes, fur and makes p ! prrr ! when I touch it, I call it a cat :))) Most of my customers are accustomed to my crude language. Since they have results when they deal with me compared to what they get internally and from other suppliers, they forgive me :))) This enterprise mindset translates most of the time into bureaucracy at the expense of results. It's understandable, delivering significant work (real stuff that runs and helps the business) is harder to create than say, heating a chair with your b... or calling endless meetings to discuss the latest buzzword on the market that should be the next killer tool : Crude ? Me ? No... just tired of putting my hands down to the shoulders in the mud left by others :))) Luc Oh, I agree with you 100%. I outlined why I wouldn't use Clojure in a project self-described as enterprise, but at risk of ranting I didn't get into how I consider the word enterprise synonymous with bloated, bureaucracy-bound, over-engineered, unoriginal and above all /expensive/ ball of tar. Ironically, enterprise has nothing to do with actual size or significance of the project. I've seen very small projects that are infected with enterprise, whereas I don't think there is anything enterprisy about, say, Google. -Luke On Mar 6, 11:07 am, lprefonta...@softaddicts.ca wrote: I agree about consultants (these days it's not anymore an synonym for expert) and the state of the market but... If you write a new software product and you are concerned with deadlines and speed in general, Java is not the way to go anymore considering the pile of code you need to do anything significant these days. More code = more people = inefficiencies. I know some business where HR and IT managers come back with this mantra that they can find Java and .Net coders, anything else is too risky or too scarce on the market. It reminds the time when you could not get fired when buying IBM mainframes. Many HR departments do not understand anything about software development in general and the profile of individuals needed. They go for the standard available bodies with a single fit all projects skill set and their batteries of psychological tests. That explains a lot why productivity is low on most projects. The landscape will change when HR changes (and managers)... seeking intelligence and initiative instead of a single static fit. (looks like StarTrek quest...) The day they will understand that software development is not a Taylor assembly line (less the efficiency), the situation will improve. You cannot get more from people that what you are asking for... I am not generally optimistic about the state of things in the software industry but we need to bring in tools that are more accessible to the masses. Clojure is one if you compared it to CL... Luc The biggest barrier to using Clojure in an enterprise environment is that enterprise projects are typically built and maintained by 100s of replaceable code-monkeys and consultants, all of which understand Java and almost none of which understand Lisp of any kind, let alone Clojure. To be honest, even if I could get away with it, I wouldn't want to inflict hell on the next person who has to fix something in my Clojure code. Even if they're a good developer, they are very unlikely to care about Clojure or functional programming. I heard of one guy in our company who wrote some web services in Scala on the grounds that they were one-off services that wouldn't need to be modified - until they were, and everyone was roundly cursing him for it. They were small enough that it turned out to be easier to redo them in Java rather than to learn Scala and understand his code. Like it or not, enterprise development = Java or .NET until the language landscape has some radical changes. --~--~-~--~~~---~--~~ 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: Chrono date library
What's the status of this JSR? Is it possible the JDK 7 will include more palatable date processing capabilities? I think it would be a shame if external libraries were required to get sane date processing in Clojure, but if the JDK 7 has potential to fix it, that's encouraging. As far as I can tell, the JSR was approved to go into Java 7, but there is some risk of them not being done by the deadline. JSR-310 is a complete re-write, I assume for licensing reasons. Most of the problems mentioned seem to be related to timezones. It seems the worst case scenario is simply to have Chrono support no timezone-aware operations out of the box on JDKs 5 and 6, but be able to offer greater capabilities if either the JDK 7 or Joda time is installed. I agree that having a more limited library is better than having one that claims to have greater capabilities, but has bugs. Yes, most problems I've encountered and read about are timezone problems. I'll keep going back to the number of days between Jan 1 and June 1 problem, because it's easy and instructive. You cannot answer that correctly without specifying a timezone. And if you don't support timezones, the only timezone where your library can be used correctly is UTC. One of the large advantages of Joda is that the API is constructed in such a way that it is obvious what will happen. For example, there are two ways to specify a duration, an Instant and a Partial. An Instant is used to say now + 86400 seconds. A partial is used to say now + 1 week. Those are two different operations because they can have two different results depending on the current year and timezone. This is actually a very convenient time to write this note, because it makes my examples easy. :-) Where I live, Daylight Savings Time happens this Sunday, and my timezone will change from Central Standard Time to Central Daylight Time. It is currently Friday Mar 6 10:40 am CST. If I ask for now + 7 days, the correct answer is Friday Mar 13, 10:40 am CDT. But if I ask for now + 86400 seconds, the correct answer is Friday Mar 13, 11:40 am CDT. Naively converting from seconds to days/weeks/months/years is not a well defined operation in most timezones. I'm not convinced the problems can't be worked around once we are made aware of them, but it definitely merits further investigation. I'm sure the problems can be worked around once you're aware of them, but a correct solution will end up with a lot of the same concepts as Joda, and definitely won't have the same API as you do now. If you base Chrono on Joda you can avoid all of that pain now. Allen --~--~-~--~~~---~--~~ 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: Workflow poll?
On Fri, Mar 6, 2009 at 11:18 AM, Paul Stadig p...@stadig.name wrote: If it works with Java, then it should be possible to get it working with Clojure, no? It may take some work, but should be possible. It wouldn't be terribly appropriate. The ODB is meant to deal with mutability in Java code and does so by instrumenting the compiled bytecode. The same thing for Clojure would deal with Clojure's expressions, immutability and concurrency sementics. It would probably do so by instrumenting the clojure code itself because that's much easier to do in a lisp. I could run the ODB on compiled clojure code but then I'd see how Rich performs his magic underneath and that's not very relevant to what I want to debug. --~--~-~--~~~---~--~~ 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: What is Clojure NOT good for?
Konrad Hinsen konrad.hin...@laposte.net writes: As for what JVM languages are not good for in general, there is the obvious domain of systems-level programming, and there are other domains such as number crunching, where there is a severe lack of good libraries in the Java world. The only other thing I can think of is short-lived command-line tools that need subsecond launch times. -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: pmap slower than map when reducing
Hi guys, anyone has an insight into the problem I'm running into? On Mar 4, 2:27 am, Dimiter \malkia\ Stanev mal...@gmail.com wrote: Hi guys, In the example below, if map is replaced with pmap, it goes twice slower on my MBP (2 CPUs). I believe it's probably the (reduce + ...) causing it, but I can't explain it. Version with map: user (time (pnpolytest)) Elapsed time: 3903.533 msecs 600 Version with pmap: user (time (pnpolytest)) Elapsed time: 7995.565 msecs What I'm doing wrong here? (defn- pnpoly [npol #^floats xp #^floats yp x y] (let [npol (int npol) x (float x) y (float y)] (loop [r (int 0) i (int 0) xi (aget xp (dec npol)) yi (aget yp (dec npol))] (if ( i npol) (let [xj xi xi (aget xp i) yj yi yi (aget yp i)] (if (or (= ( yi y) ( yj y)) (= x (+ xi (/ (* (- xj xi) (- y yi)) (- yj yi) (recur (bit-not r) (inc i) xi yi) (recur r (inc i) xi yi))) (- r) (defn pnpolytest [] (let [xp (float-array [+0.0 +1.0 +1.0 +0.0 +0.0 +1.0 -0.5 -1.0 -1.0 -2.0 -2.5 -2.0 -1.5 -0.5 +1.0 +1.0 +0.0 -0.5 -1.0 -0.5]) yp (float-array [+0.0 +0.0 +1.0 +1.0 +2.0 +3.0 +2.0 +3.0 0.0 -0.5 -1.0 -1.5 -2.0 -2.0 -1.5 -1.0 -0.5 -1.0 -1.0 -0.5]) npol 20] (reduce + ;; Replace the nex map with pmap, ;; and things slow down (map (fn [_] (+ (pnpoly npol xp yp 0.5 0.5) (pnpoly npol xp yp 0.5 1.5) (pnpoly npol xp yp -0.5 1.5) (pnpoly npol xp yp 0.75 2.25) (pnpoly npol xp yp 0.0 2.01) (pnpoly npol xp yp -0.5 2.5) (pnpoly npol xp yp -1.0 -0.5) (pnpoly npol xp yp -1.5 0.5) (pnpoly npol xp yp -2.25 -1.0) (pnpoly npol xp yp 0.5 -0.25) (pnpoly npol xp yp 0.5 -1.25) (pnpoly npol xp yp -0.5 -2.5))) (range 0 100) Thanks, Dimiter malkia Stanev --~--~-~--~~~---~--~~ 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: What is Clojure NOT good for?
Hi, Am 06.03.2009 um 19:21 schrieb Phil Hagelberg: The only other thing I can think of is short-lived command-line tools that need subsecond launch times. Even this can be addressed via Nailgun as I use it now for dynamic VimClojure (aka Gorilla). A server runs in the background and invoking the cli tool just talks to the server, taking care of startup times. Not perfect, but for certain uses (eg. making Clojure with Vim more fun) it is sufficient. :) Sincerely Meikel smime.p7s Description: S/MIME cryptographic signature
Re: What is Clojure NOT good for?
Clojure is not good for: - Real time application development, due to the JVM being soft-real time. For example it can't be used for high-performance video pc/ console games, but it could be used for lots of turn-based games. Then again anything done with XNA on the XBOX could be done with Clojure :) (XNA is some form of Compact .NET for the XBOX). - Writing small utility programs, as it requires certain things to be installed properly (For example using java -serever with the correct JVM). For example I can't see myself deploying small utility application at work written with Clojure, as it would make people screaming, why they have to install this and that. That won't be the case with big and important application (noone would mind the hidden JVM that I might put along with it). On Mar 6, 5:15 am, Joshua Fox joshuat...@gmail.com wrote: Is it fair to say that Clojure shines in algorithmic processing, string processing, concurrency management, but that there are better choices in other areas: - Application programming , where the key challenge is fitting a standard three-tier application to the business domain. - Enterprise programming, where the challenge is gluing together overweight and fragile libraries, and one should always use exactly the set of software which the API creators envisioned? Rich himself has suggested something along these lines, but I wonder what others think. Joshua --~--~-~--~~~---~--~~ 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: Workflow poll?
levand luke.vanderh...@gmail.com writes: I use Emacs+Slime in windows (I'd prefer a Mac if I could afford one) as my primary development environment. I start Emacs with a project- specific batch file that adds all the libraries I use to the CLASSPATH environment variable and then invokes Emacs, so all I have to do to add a new library to the project is to dump it in the lib folder in my project, and add a line in the bat file. Rather than launching Emacs with a batch file that sets an environment var, it's probably better to set your classpath in elisp. That way you can take an existing Emacs instance and start using it for clojure dev without restarting it. Here's what I use for Mire: http://github.com/technomancy/mire/blob/30486954d36b8e55c6dad90bd8bd0bdeeaf32131/mire.el Since my app provides telnet access (it's a MUD), I also define an Emacs function to launch a telnet buffer to try things out. Currently I am in an effort to put my existing code, except for the UI portions, under complete test coverage using the test-is library. To keep things clean, I am putting all the tests for each file in a separate file. Making sure your library has automated tests is essential, but I find it's usually a lot of tedious work to add tests after your code is written. It's a much smoother workflow to write your tests first. This has the triple benefit of forcing you to think about the shape of your API up front, letting you know when your implementation is working correctly, and leaving you with a full regression suite when you're done at no extra effort. Of course you have to learn to test the right things and know what edge cases to watch for, but this comes with time. As you're starting out it's better to err on the side of comprehensiveness. Since you're already using SLIME, you might be interested in clojure-test-mode.el: http://github.com/technomancy/clojure-mode/blob/77a91fbcb352e23afe3f284aa6d2f9de4bb4f9a0/clojure-test-mode.el This allows you to get instant feedback from test runs within your buffer, highlighting failures in red and errors in brown. I've found it's streamlined my workflow immensely. It's still pretty new though, so be sure to let me know how it works for you if you try it out. This is actually my first experience with unit tests. The motivator for it is a problem I am still struggling with - my time spent debugging is increasing exponentially relative to the amount of code I have. Hopefully unit tests, in conjunction with writing smaller, more atomic functions will allow me to have more confidence in individual functions which will ease the debugging process. My approach in these situations is to start with a high-level test, and if this doesn't work, break it down into more and more specific tests until you find the specific function or situation that breaks. Of course, performing this effectively depends a lot on intuition in more complicated codebases, so it's definitely tricky to know what to test next when you're starting out. In my experience, debuggers are good for two things: investigating bugs in your infrastructure (in Clojure or other dependencies) and investigating performance problems. If you are feeling the need to step into a debugger to deal with correctness problems, it's merely a sign that your test suite is lacking in coverage. -Phil http://technomancy.us --~--~-~--~~~---~--~~ 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: pmap slower than map when reducing
It is pretty common to get a slowdown when moving from map to pmap. It just means that the thread scheduling overhead is greater than the gain from parallelizing the code. The behavior might be very different w/ larger data sets, or w/ more CPU's. It is often best to leave parallelism as an option to the client of your library. Are you using the latest build? pmap now uses Java futures and they run in a cached thread pool. If so, try running the algorithm a few times and see if it speeds up as the thread pool winds up. On Fri, Mar 6, 2009 at 1:31 PM, Dimiter malkia Stanev mal...@gmail.comwrote: Hi guys, anyone has an insight into the problem I'm running into? On Mar 4, 2:27 am, Dimiter \malkia\ Stanev mal...@gmail.com wrote: Hi guys, In the example below, if map is replaced with pmap, it goes twice slower on my MBP (2 CPUs). I believe it's probably the (reduce + ...) causing it, but I can't explain it. Version with map: user (time (pnpolytest)) Elapsed time: 3903.533 msecs 600 Version with pmap: user (time (pnpolytest)) Elapsed time: 7995.565 msecs What I'm doing wrong here? (defn- pnpoly [npol #^floats xp #^floats yp x y] (let [npol (int npol) x (float x) y (float y)] (loop [r (int 0) i (int 0) xi (aget xp (dec npol)) yi (aget yp (dec npol))] (if ( i npol) (let [xj xi xi (aget xp i) yj yi yi (aget yp i)] (if (or (= ( yi y) ( yj y)) (= x (+ xi (/ (* (- xj xi) (- y yi)) (- yj yi) (recur (bit-not r) (inc i) xi yi) (recur r (inc i) xi yi))) (- r) (defn pnpolytest [] (let [xp (float-array [+0.0 +1.0 +1.0 +0.0 +0.0 +1.0 -0.5 -1.0 -1.0 -2.0 -2.5 -2.0 -1.5 -0.5 +1.0 +1.0 +0.0 -0.5 -1.0 -0.5]) yp (float-array [+0.0 +0.0 +1.0 +1.0 +2.0 +3.0 +2.0 +3.0 0.0 -0.5 -1.0 -1.5 -2.0 -2.0 -1.5 -1.0 -0.5 -1.0 -1.0 -0.5]) npol 20] (reduce + ;; Replace the nex map with pmap, ;; and things slow down (map (fn [_] (+ (pnpoly npol xp yp 0.5 0.5) (pnpoly npol xp yp 0.5 1.5) (pnpoly npol xp yp -0.5 1.5) (pnpoly npol xp yp 0.75 2.25) (pnpoly npol xp yp 0.0 2.01) (pnpoly npol xp yp -0.5 2.5) (pnpoly npol xp yp -1.0 -0.5) (pnpoly npol xp yp -1.5 0.5) (pnpoly npol xp yp -2.25 -1.0) (pnpoly npol xp yp 0.5 -0.25) (pnpoly npol xp yp 0.5 -1.25) (pnpoly npol xp yp -0.5 -2.5))) (range 0 100) Thanks, Dimiter malkia Stanev --~--~-~--~~~---~--~~ 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: Chrono date library
Allen Rohner aroh...@gmail.com writes: As far as I can tell, the JSR was approved to go into Java 7, but there is some risk of them not being done by the deadline. JSR-310 is a complete re-write, I assume for licensing reasons. Interesting. One of the large advantages of Joda is that the API is constructed in such a way that it is obvious what will happen. For example, there are two ways to specify a duration, an Instant and a Partial. An Instant is used to say now + 86400 seconds. A partial is used to say now + 1 week. Those are two different operations because they can have two different results depending on the current year and timezone. What this means to me is that the earlier, later, and time-between functions will need to behave differently if the units used are variable-length (days and up) vs invariable (seconds, minutes, hours). This is actually a very convenient time to write this note, because it makes my examples easy. :-) Where I live, Daylight Savings Time happens this Sunday, and my timezone will change from Central Standard Time to Central Daylight Time. It is currently Friday Mar 6 10:40 am CST. If I ask for now + 7 days, the correct answer is Friday Mar 13, 10:40 am CDT. But if I ask for now + 86400 seconds, the correct answer is Friday Mar 13, 11:40 am CDT. Naively converting from seconds to days/weeks/months/years is not a well defined operation in most timezones. I don't think it would be too hard to remove naive conversions between days/weeks etc and seconds from Chrono. But I do agree that it shouldn't be adopted for any use until this is done. And it may be harder than I suspect. We'll see. I'm not convinced the problems can't be worked around once we are made aware of them, but it definitely merits further investigation. I'm sure the problems can be worked around once you're aware of them, but a correct solution will end up with a lot of the same concepts as Joda, and definitely won't have the same API as you do now. If you base Chrono on Joda you can avoid all of that pain now. Yes, but any library that requires third-party jars can't be used out of the box in contrib, and I think a language that doesn't support date-processing out of the box is at a severe disadvantage. -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: Clojure infinite loop
On Fri, Mar 6, 2009 at 7:24 AM, mike.farn...@gmail.com mike.farn...@gmail.com wrote: Hi, Having attend Stu Halloway's talk on Clojure, at NFJS, I decided to download it and check it out. The language seems like a perfect fit for some database set manipulation that I do, and may need to do in the future. So, I downloaded clojure and started it up with the command: java -cp clojure.jar clojure.lang.Repl The docs indicate: This will bring up a simple read-eval-print loop (REPL). Is this truly an infinite loop? Yes. Unless you break out of it in some way :) -- Michael Wood esiot...@gmail.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: Workflow poll?
In my experience, debuggers are good for two things: investigating bugs in your infrastructure (in Clojure or other dependencies) and investigating performance problems. If you are feeling the need to step into a debugger to deal with correctness problems, it's merely a sign that your test suite is lacking in coverage. It's also good to figure out what exactly your program does. It might be because you aren't that familiar with the language yet. Or maybe the bastard who handed the code to you didn't create a good test suite. --~--~-~--~~~---~--~~ 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: What is Clojure NOT good for?
- Writing small utility programs, as it requires certain things to be installed properly (For example using java -serever with the correct JVM). For example I can't see myself deploying small utility application at work written with Clojure, as it would make people screaming, why they have to install this and that. That won't be the case with big and important application (noone would mind the hidden JVM that I might put along with it). Couldn't clojure compiled binaries be put into an executable (self- contained) jar file? --~--~-~--~~~---~--~~ 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 infinite loop
On Fri, Mar 6, 2009 at 5:00 PM, Stephen C. Gilardi squee...@mac.com wrote: On Mar 6, 2009, at 9:44 AM, Mark Volkmann wrote: ctrl-c is the right way to exit under Windows. Under UNIX, Linux and Mac OS X, I think ctrl-d is preferred. I agree. Here's some more info: On the Unixes, ctl-d represents end-of-file (end of input stream). Usually terminals and terminal-like interfaces will send ctl-d immediately to the process waiting for input even in cases where input would normally be line-buffered before being sent. ctl-d works to quit the repl immediately on Linux and Mac OS X. On Windows the corresponding end-of-file marker is ctl-z. However in a default cmd window ctl-z doesn't act immediately. Instead, it's interpreted after pressing return. Both ctl-z return and ctl-c work to quit the clojure Repl on Windows. As the latter is more succinct, I think it's reasonable for it to be preferred. I tend to use Ctrl-D on Linux/Mac and Ctrl-Z on Windows. The same goes for Python (and sbcl, and psql, and mysql, and bash etc.) This is partly because Ctrl-C doesn't work for exiting the Python REPL, but actually, I think the Python behaviour is more useful: With Python you can use Ctrl-C to break out of long-running functions/infinite loops. Basically you get a KeyboardInterrupt exception thrown: while True: ... pass ... (Ctrl-C pressed here) Traceback (most recent call last): File stdin, line 1, in module KeyboardInterrupt PostgreSQL's command line client, psql, behaves similarly. If you accidentally issue an SQL statement that takes far longer than you meant it to, you can press Ctrl-C and be back where you were before you ran it. With MySQL the mysql client gets killed and you're back at your shell prompt. I feel psql's behaviour is much more friendly. -- Michael Wood esiot...@gmail.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: Chrono date library
On Fri, Mar 6, 2009 at 9:18 PM, Phil Hagelberg p...@hagelb.org wrote: Allen Rohner aroh...@gmail.com writes: [...] One of the large advantages of Joda is that the API is constructed in such a way that it is obvious what will happen. For example, there are two ways to specify a duration, an Instant and a Partial. An Instant is used to say now + 86400 seconds. A partial is used to say now + 1 week. Those are two different operations because they can have two different results depending on the current year and timezone. What this means to me is that the earlier, later, and time-between functions will need to behave differently if the units used are variable-length (days and up) vs invariable (seconds, minutes, hours). [...] Just to be pedantic, minutes are also occasionally variable: http://en.wikipedia.org/wiki/Leap_second -- Michael Wood esiot...@gmail.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: What is Clojure NOT good for?
Real time is a special application domain. I am not sure that most people want to work in this domain (I did for several years with VMS and a power utility). As for start up time for small utility commands I disagree, this is something that could change if we start to use the hardware a bit more wisely one day. I work with Ubuntu and all my frequently used tools are copied to RAM (/tmpfs) at boot time. My Java environment is there, Clojure, Eclipse, frequently used librairies... On top of that there's a daemon running to spot my frequently accessed files and serve them from RAM transparently. It takes me less than 1.3 secs to get the REPL prompt. Combine that with the approach of having a Clojure server in the background and that's it. Server is not there ? It gets started automatically in less than 2 sec. and runs your stuff, it's already started ? Well, it runs your commands immediately. Ok, I have 6 gigs of RAM and a quad core (Q6600) and disk mirroring but I cannot consume more than 60% of the RAM and 10% of the swap space. I run Oracle server, ActiveMq, Terracotta2, two copies of Eclipse most of the time and our application services on my desktop concurrently. As to how I can get this machine down on it's knees begging me to stop, well I did not find a way in my day to day work yet. With a dual core and 3gig of RAM at entry level prices, there are no excuses to have a slow environment. You just have to figure a nice way to use the power at your disposal. I am always ashamed when I see the kind of desktops developers get from their employers. I saw many sites where developers have desktops not more powerful than the average office user. That's poor planning. The time spent waiting by the developer after the hardware is a significant hidden cost but it seems that no manager wants to tackle this issue and defend a wiser buying strategy to get power where it's needed... no top executive needs a quad core desktop with tons of RAM. On one project just by changing to this Ferrari, I shrank the build-restart-application-ready to test cycle from 90 seconds to 8. When I started to code, computers were less powerful than the standard pocket calculator but we were doing a lot my designing accordingly. It's far more easier today given the amount of resources we have Luc On Fri, 2009-03-06 at 10:39 -0800, Dimiter malkia Stanev wrote: Clojure is not good for: - Real time application development, due to the JVM being soft-real time. For example it can't be used for high-performance video pc/ console games, but it could be used for lots of turn-based games. Then again anything done with XNA on the XBOX could be done with Clojure :) (XNA is some form of Compact .NET for the XBOX). - Writing small utility programs, as it requires certain things to be installed properly (For example using java -serever with the correct JVM). For example I can't see myself deploying small utility application at work written with Clojure, as it would make people screaming, why they have to install this and that. That won't be the case with big and important application (noone would mind the hidden JVM that I might put along with it). On Mar 6, 5:15 am, Joshua Fox joshuat...@gmail.com wrote: Is it fair to say that Clojure shines in algorithmic processing, string processing, concurrency management, but that there are better choices in other areas: - Application programming , where the key challenge is fitting a standard three-tier application to the business domain. - Enterprise programming, where the challenge is gluing together overweight and fragile libraries, and one should always use exactly the set of software which the API creators envisioned? Rich himself has suggested something along these lines, but I wonder what others think. Joshua -- Luc Préfontaine Off.:(514) 993-0320 Fax.:(514) 993-0325 Armageddon was yesterday, today we have a real 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 infinite loop
(Ctrl-C pressed here) Traceback (most recent call last): File stdin, line 1, in module KeyboardInterrupt That is something I miss from SBCL. In SLIME-SBCL, you can just Ctrl- C Ctrl-C to interrupt your code. I think it's not possible (or at least easy) in Clojure without adding debugging cruft to your compiled code, since in general once your code gets going there's no safe way to stop it. (In the future, this might be a nice option to add to the compiler ...). Killing threads is depracated in Java since it can cause all sorts of nastiness. This was one of my motivations for writing these timing utils: http://groups.google.com/group/clojure/browse_frm/thread/231cc06b4b13744c?hl=en# If you wrap your code in time-limit, and make sure to call (timeout) periodically within it, it will automatically be killed if it runs too long. And, even if you don't run your code in a time-limit, you can call (interrupt-all-threads) to kill it. This also screws with the REPL and other threads in the ecosystem, but I've found that in SLIME I can usually just start up a new REPL and pick up where I left off without losing any state. I'm sure this could be improved upon greatly, but it's worked for me so far. Cheers, Jason --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
clojure.contrib.stacktrace
What's the recommended way to use this library in code that is run outside a REPL to simplify stack traces so they focus on Clojure code instead of Java code? I tried something like this, but it didn't work. (use 'clojure.contrib.stacktrace) ... lots of code including definition of a main function ... (try (main) (catch Exception e (print-stack-trace e 5))) -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Unicode, accented characters
Hi, I'm trying to output accented characters from clojure. Actually, I'm trying to call setToolTipText on a JComponent with some unicode string. No problems doing so from Java, but with clojure I'm hitting a wall. In REPL: exmentis= àéôö →∟↔ exmentis= \u00f4 \├┤ exmentis= \u00c0 \├Ç Ok, so the Reader doesn't read my input correctly, right? Let's make a Java static member: class Application { public static final String abc = àààèèè; } (Application is loaded in REPL by being on the classpath.) exmentis= Application/abc ├á├á├á├¿├¿├¿ exmentis= (println Application/abc) ├á├á├á├¿├¿├¿ nil exmentis= (. System/out println Application/abc) αααΦΦΦ nil (note the difference in output) Hmmm... not better. BTW, doing System.out.println(Application.abc) from Java outputs the correct result. To put it simply, whenever I define a unicode String in Java, I obtain the right result as long as I stay on the Java side. For instance (. component setToolTipText Application/abc) ;; works (. component setToolTipText àéö) ;; doesn't work (garbled output) What am I missing? Clojure uses Java strings, right? exmentis= (instance? String àéè) true Why is the Reader not able to understand the string correctly then? Max P.S. I showed REPL output in this post but the way I actually do things is to load clojure scripts from Java with RT.loadResourceScript (). It doesn't work this way either. (BTW, my REPL is: java -cp %ADD_CP%;%CLOJURE_DIR%\jline-0.9.94.jar;%CLOJURE_JAR% jline.ConsoleRunner clojure.lang.Repl where ADD_CP is some additional classpaths.) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
How do I setup Clojure REPL to automattically use some libraries?
Does anyone know if there is a way to setup your Clojure REPL with an initialization file like how SBCL works with a .sbclrc file? I'd like to have my REPL automattically use some of the libraries in clojure.contrib such as the repl-utils and the stacktrace libraries whenever it first loads. Thanks for your in advance. Christopher --~--~-~--~~~---~--~~ 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: pmap slower than map when reducing
Thanks! Realized that a bit too late (Looked into the pmap source code, but that's about it). I've split my job decision roughly 1000 x 1000 - now I'm getting 8 times speedup, on 8 core machine: (reduce + (pmap (fn [_] (reduce + (map (fn [_] (+ (pnpoly np xp yp 0.5 0.5) (pnpoly np xp yp 0.5 1.5) (pnpoly np xp yp -0.5 1.5) (pnpoly np xp yp 0.75 2.25) (pnpoly np xp yp 0.0 2.01) (pnpoly np xp yp -0.5 2.5) (pnpoly np xp yp -1.0 -0.5) (pnpoly np xp yp -1.5 0.5) (pnpoly np xp yp -2.25 -1.0) (pnpoly np xp yp 0.5 -0.25) (pnpoly np xp yp 0.5 -1.25) (pnpoly np xp yp -0.5 -2.5))) (range 0 1000 (range 0 1000))) Clojure is reasonable :) Jeffrey Straszheim wrote: It is pretty common to get a slowdown when moving from map to pmap. It just means that the thread scheduling overhead is greater than the gain from parallelizing the code. The behavior might be very different w/ larger data sets, or w/ more CPU's. It is often best to leave parallelism as an option to the client of your library. Are you using the latest build? pmap now uses Java futures and they run in a cached thread pool. If so, try running the algorithm a few times and see if it speeds up as the thread pool winds up. On Fri, Mar 6, 2009 at 1:31 PM, Dimiter malkia Stanev mal...@gmail.comwrote: Hi guys, anyone has an insight into the problem I'm running into? On Mar 4, 2:27 am, Dimiter \malkia\ Stanev mal...@gmail.com wrote: Hi guys, In the example below, if map is replaced with pmap, it goes twice slower on my MBP (2 CPUs). I believe it's probably the (reduce + ...) causing it, but I can't explain it. Version with map: user (time (pnpolytest)) Elapsed time: 3903.533 msecs 600 Version with pmap: user (time (pnpolytest)) Elapsed time: 7995.565 msecs What I'm doing wrong here? (defn- pnpoly [npol #^floats xp #^floats yp x y] (let [npol (int npol) x (float x) y (float y)] (loop [r (int 0) i (int 0) xi (aget xp (dec npol)) yi (aget yp (dec npol))] (if ( i npol) (let [xj xi xi (aget xp i) yj yi yi (aget yp i)] (if (or (= ( yi y) ( yj y)) (= x (+ xi (/ (* (- xj xi) (- y yi)) (- yj yi) (recur (bit-not r) (inc i) xi yi) (recur r (inc i) xi yi))) (- r) (defn pnpolytest [] (let [xp (float-array [+0.0 +1.0 +1.0 +0.0 +0.0 +1.0 -0.5 -1.0 -1.0 -2.0 -2.5 -2.0 -1.5 -0.5 +1.0 +1.0 +0.0 -0.5 -1.0 -0.5]) yp (float-array [+0.0 +0.0 +1.0 +1.0 +2.0 +3.0 +2.0 +3.0 0.0 -0.5 -1.0 -1.5 -2.0 -2.0 -1.5 -1.0 -0.5 -1.0 -1.0 -0.5]) npol 20] (reduce + ;; Replace the nex map with pmap, ;; and things slow down (map (fn [_] (+ (pnpoly npol xp yp 0.5 0.5) (pnpoly npol xp yp 0.5 1.5) (pnpoly npol xp yp -0.5 1.5) (pnpoly npol xp yp 0.75 2.25) (pnpoly npol xp yp 0.0 2.01) (pnpoly npol xp yp -0.5 2.5) (pnpoly npol xp yp -1.0 -0.5) (pnpoly npol xp yp -1.5 0.5) (pnpoly npol xp yp -2.25 -1.0) (pnpoly npol xp yp 0.5 -0.25) (pnpoly npol xp yp 0.5 -1.25) (pnpoly npol xp yp -0.5 -2.5))) (range 0 100) Thanks, Dimiter malkia Stanev --~--~-~--~~~---~--~~ 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: Unicode, accented characters
Hi, Am 06.03.2009 um 23:31 schrieb max3000: I'm trying to output accented characters from clojure. Actually, I'm trying to call setToolTipText on a JComponent with some unicode string. No problems doing so from Java, but with clojure I'm hitting a wall. In REPL: exmentis= àéôö →∟↔ exmentis= \u00f4 \├┤ exmentis= \u00c0 \├Ç Clojure user= àéñî àéñî Works For Me(tm). Ok, so the Reader doesn't read my input correctly, right? No. I think it reads it correctly. jline.ConsoleRunner I got a bit weird behaviour with jline.ConsoleRunner. Try without it. That worked for me. Sincerely Meikel smime.p7s Description: S/MIME cryptographic signature
Re: How do I setup Clojure REPL to automattically use some libraries?
On Fri, Mar 6, 2009 at 4:33 PM, Christopher vth...@gmail.com wrote: Does anyone know if there is a way to setup your Clojure REPL with an initialization file like how SBCL works with a .sbclrc file? I'd like to have my REPL automattically use some of the libraries in clojure.contrib such as the repl-utils and the stacktrace libraries whenever it first loads. Thanks for your in advance. IIRC Clojure will automatically load user.clj if found in CLASSPATH, so I think it would be a good place to put any kind of customizations. -- Cosmin Stejerean http://offbytwo.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 -~--~~~~--~~--~--~---
Shouldn't doto be named just with
I've just started using doto, after seeing the celsius example on the Clojure page, but It brought back memories from Pascal days - http://csci.csusb.edu/dick/samples/pascal.syntax.html#with_statement It's probably nothing, but to me (with x (.Function1) (.Function2)) seems more readable than (doto). Off course I'm already used to doto (spend almost 10 minutes on it), and Common Lisp learned me to be okay with any names, because once you learn it, the name is just a memo to what the semantics are. But still It might be more approachable to a newbie to use with, rather than doto. Then again, the whole with- convention is a whole other topic. Just wanted to share with you! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
calling overloaded Java methods
The code below gives java.lang.IllegalArgumentException: More than one matching method found: submit. Is there a way to tell Clojure which submit method I want? (defn do-stuff [] (+ 2 2)) (let [executor (java.util.concurrent.Executors/newSingleThreadExecutor) future (.submit executor #(do-stuff))] (println (.get future))) -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~~---~--~~ 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: Shouldn't doto be named just with
Hello, I'm not sure about this, but I think doto is named after the convention that a lot of side effecting functions/macros/special forms follow : share the do prefix if the name implies that there will be side effects. And indeed, if you use doto with more than one following expression, then this list of expression will generate side effects (mutating the target object, at a minimum). My 0,02€, -- Laurent 2009/3/7 Dimiter malkia Stanev mal...@gmail.com I've just started using doto, after seeing the celsius example on the Clojure page, but It brought back memories from Pascal days - http://csci.csusb.edu/dick/samples/pascal.syntax.html#with_statement It's probably nothing, but to me (with x (.Function1) (.Function2)) seems more readable than (doto). Off course I'm already used to doto (spend almost 10 minutes on it), and Common Lisp learned me to be okay with any names, because once you learn it, the name is just a memo to what the semantics are. But still It might be more approachable to a newbie to use with, rather than doto. Then again, the whole with- convention is a whole other topic. Just wanted to share with you! --~--~-~--~~~---~--~~ 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 infinite loop
I just added a couple functions to clojure.contrib.repl-utils in an attempt to support Ctrl-C: user= (use 'clojure.contrib.repl-utils) nil user= (add-break-thread!) {1 #WeakReference java.lang.ref.weakrefere...@e29820} This registers the current thread to be stopped next time an INT signal is recieved, which happens when the user presses Ctrl-C. Try this: user= (Thread/sleep 1) Then press Ctrl-C before the 10 seconds are up, and you'll see: java.lang.Exception: SIGINT (NO_SOURCE_FILE:0) user= ...and you're back at the repl so you can try something else. This works for busy loops and should work for IO and other blocking behavior. Sweet, that is slicker than my solution. It works for me seamlessly in SLIME at the inferior-lisp REPL. For expressions typed at the slime-repl I have to switch to the inferior-lisp buffer to send the C- C C-C signal, which also kills the slime-repl in the process. Anyway, the Lisp process seems to survive, and I can easily start a new REPL, so this isn't the end of the world. Thanks! Jason --~--~-~--~~~---~--~~ 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: calling overloaded Java methods
On Mar 6, 3:23 pm, Mark Volkmann r.mark.volkm...@gmail.com wrote: The code below gives java.lang.IllegalArgumentException: More than one matching method found: submit. Is there a way to tell Clojure which submit method I want? (defn do-stuff [] (+ 2 2)) (let [executor (java.util.concurrent.Executors/newSingleThreadExecutor) future (.submit executor #(do-stuff))] (println (.get future))) (let [executor (java.util.concurrent.Executors/ newSingleThreadExecutor) future (.submit executor #^Callable #(do-stuff))] (println (.get future))) == 4 Cheers, Jason --~--~-~--~~~---~--~~ 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: Shouldn't doto be named just with
Hi, Am 07.03.2009 um 00:23 schrieb Laurent PETIT: I'm not sure about this, but I think doto is named after the convention that a lot of side effecting functions/macros/special forms follow : share the do prefix if the name implies that there will be side effects. And indeed, if you use doto with more than one following expression, then this list of expression will generate side effects (mutating the target object, at a minimum). I think doto is actually a good name. In contrast to -, which uses the return value of the expressions doto always calls the given functions or methods using the initial thing. So it does the function calls to the thing. Together with the points Laurent mentioned about the do-prefix indicating side-effects and the slightly different notion of the with-something blocks, I think doto is just good enough a name. Just, my 2¢ and YMMV. Sincerely Meikel smime.p7s Description: S/MIME cryptographic signature
Re: How do I setup Clojure REPL to automattically use some libraries?
Hey, thanks so much guys, that's exactly what I was looking for. I completely forgot about this since it's been so long since I read the Getting Started portion of the Clojure website. Anyway, it may be helpful for other's like me who are looking for a similar answer to know that to get this to work, the directory within which your user.clj file resides needs to be on the CLASSPATH, not the file itself. Also, I made mine a pointer to a .cljrc file in my home directory so that I could keep all of my init code in a similar place/format. Thanks again for the help. Christopher On Mar 6, 2:49 pm, Paul Stadig p...@stadig.name wrote: You can create a user.clj file in your classpath, and it will get loaded when Clojure is run, with the REPL or not. Paul On 3/6/09, Christopher vth...@gmail.com wrote: Does anyone know if there is a way to setup your Clojure REPL with an initialization file like how SBCL works with a .sbclrc file? I'd like to have my REPL automattically use some of the libraries in clojure.contrib such as the repl-utils and the stacktrace libraries whenever it first loads. Thanks for your in advance. Christopher --~--~-~--~~~---~--~~ 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: Shouldn't doto be named just with
I think good arguments have been made for doto, but I must say I prefer with slightly more. FWIW, Groovy calls it with. http://javajeff.blogspot.com/2008/11/getting-groovy-with-with.html The great thing about Clojure is that if this really bothered me I could easily take matters into my own hands. (defmacro with [x forms] `(doto ~x ~...@forms)) Clojure rocks! On Mar 6, 7:36 pm, Dimiter \malkia\ Stanev mal...@gmail.com wrote: Thanks for the explanation guys! Having learned other languages, sometimes makes you wanna have the MEMORY UNDO FEATURE! On Mar 6, 3:37 pm, Meikel Brandmeyer m...@kotka.de wrote: Hi, Am 07.03.2009 um 00:23 schrieb Laurent PETIT: I'm not sure about this, but I think doto is named after the convention that a lot of side effecting functions/macros/special forms follow : share the do prefix if the name implies that there will be side effects. And indeed, if you use doto with more than one following expression, then this list of expression will generate side effects (mutating the target object, at a minimum). I think doto is actually a good name. In contrast to -, which uses the return value of the expressions doto always calls the given functions or methods using the initial thing. So it does the function calls to the thing. Together with the points Laurent mentioned about the do-prefix indicating side-effects and the slightly different notion of the with-something blocks, I think doto is just good enough a name. Just, my 2¢ and YMMV. Sincerely Meikel smime.p7s 5KViewDownload --~--~-~--~~~---~--~~ 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: Unicode, accented characters
On Mar 6, 5:58 pm, max3000 maxime.lar...@gmail.com wrote: I don't really want to use the SVN version because I'm developing an application and can really do without the (normal) instabilities that come with development builds. FYI, you may want to consider using SVN for now because there have been breaking changes[1] since the last release. The general consensus seems to be that breaking changes are allowed until version 1.0 is released. Most of the commits are bug fixes, so IMO it only gets more stable, not less. 1: http://clojure.org/lazier --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
r994 UTF8 addition broke latin-1 characters (ISO-8859-1) - WAS: Re: Unicode, accented characters
There is definitely a bug. In r994 (Aug 07, 2008) UTF8 encoding was added to *in*, *out* and *err*. This messes up the Repl (and the Reader in general) as discussed above. Case in point, everything works fine when I go in the code and modify RT.java as follows: final static public Var OUT = Var.intern(CLOJURE_NS, Symbol.create(*out*), new OutputStreamWriter (System.out)); //, UTF8)); final static public Var IN = Var.intern(CLOJURE_NS, Symbol.create(*in*), new LineNumberingPushbackReader(new InputStreamReader (System.in))); //, UTF8))); (UTF8 commented out) Anyway this could be seen as a bug? Should I report it? Was this made like this for a reason? Thanks, Max On Mar 6, 8:03 pm, rzeze...@gmail.com rzeze...@gmail.com wrote: On Mar 6, 5:58 pm, max3000 maxime.lar...@gmail.com wrote: I don't really want to use the SVN version because I'm developing an application and can really do without the (normal) instabilities that come with development builds. FYI, you may want to consider using SVN for now because there have been breaking changes[1] since the last release. The general consensus seems to be that breaking changes are allowed until version 1.0 is released. Most of the commits are bug fixes, so IMO it only gets more stable, not less. 1:http://clojure.org/lazier --~--~-~--~~~---~--~~ 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: float vs fraction (just playing around)
On Mar 5, 2009, at 8:00 PM, mike.farn...@gmail.com wrote: I thought it neat that clojure supports fractions (just like Smalltalk). user= (/ 3) 1/3 I was sort of surprised by this. user= (+ (float (* (/ 2) (/ 3))) (float (* (/ 2) (/ 3))) ) 0.3334 It comes as no surprise that certain numbers cannot be represented by a finite string of decimal digits. We all realize that 1/3 = 0...., and the ... part is critical. Take it away and the equality goes away too. In other words, if that string of 3's stops, then we don't have 1/3 anymore. This situation is true inside the computer too. The floating-point representation of 1/3 is binary 0.01010101010101... Whereas in decimal we have 1/3 = 3*1/10 + 3*1/100 + 3*1/1000 + ..., in binary we have 1/3 = 0*1/2 + 1*1/4 + 0*1/8 + 1*1/16 + ... If this sum stops we once again lose equality. However, the computer only has finite memory in which to represent a floating-point number, so the string of 01s does in fact stop. The computer cannot represent 1/3 exactly in floating-point. Suppose for the sake of argument that the computer only stores the equivalent of 4 decimal digits. So we get 1/3 - 0.. But the true value is 0. 1/3 0.3334. In terms of the binary representation, depending on how many bits are used the decimal representation may be slightly closer to 0.3334 rather than 0.. You saw that by using the float function, which coerces the Ratio 1/3 to a single-precision float: (float 1/3) = 0.3334 If you had coerced to a double-precision float you would have seen this: (double 1/3) = 0. Neither one of these is more correct per se (the double is more precise of course). They simply reflect the limitations of different finite representations of 1/3. You can explore on your own by using Clojure's rationalize function (which as far as I can tell mirrors Common Lisp's RATIONAL function rather than its RATIONALIZE function): (rationalize (float 1/3)) = 41679084301/1250 (rationalize (double 1/3)) = /1 How close are these to the true values? (- (rationalize (float 1/3)) 1/3) = 37252903/3750 (- 1/3 (rationalize (double 1/3))) = 1/3 So the single-precision representation is slightly more than 1/3, which is why you see the terminal 4. Here's a little program to help you look inside 1/3. Just type (dec2bin/display-one-third PRECISION) where PRECISION is either float or double (you will need to widen your terminal window): (ns dec2bin (:use clojure.contrib.math)) (defn integer-to-binary [i] (if (zero? i) 0 (loop [i i result ] (if (zero? i) (apply str result) (recur (quot i 2) (if (zero? (rem i 2)) (cons \0 result) (cons \1 result ))) (defn fraction-to-binary [x digits] (loop [n digits fraction x result ] (if (zero? n) (apply str (reverse result)) (let [whole (quot (* 2 fraction) 1) fraction (rem (* 2 fraction) 1)] (recur (dec n) fraction (cons (char (+ whole (int \0))) result )) (defn decimal-to-binary ([x] (decimal-to-binary x 10)) ([x digits] (let [whole (integer-to-binary (quot x 1)) fraction (fraction-to-binary (rem x 1) digits)] (format %s.%s whole fraction (defn display-one-third [f] (prn (format %5s %-20s %-40s %s bits floating-point fraction binary)) (let [precision (if (= f float) 16 32)] (dotimes [i precision] (let [j (inc i) sum (reduce + (map #(/ (expt 2 (* 2 %))) (range 1 (inc j] (prn (format %5d %-20s %-40s %s (* 2 j) (str (f sum)) (str sum) (decimal-to-binary sum (* 2 j (= (+ (float (* (/ 2) (/ 3))) (float (* (/ 2) (/ 3))) ) (/ 3) ) yields true You have to be very careful comparing floating-point numbers. While the above discussion of 1/3 should not be surprising, many people do get surprised when they look at other numbers in floating-point. A perfect example is 0.1. In decimal, this looks like a nice fraction that terminates after 1 decimal place. However, binary fractions are not represented using powers of 10: 1/10, 1/100, 1/1000, etc. We have to represent 0.1 in terms of: 1/2, 1/4, 1/8, etc. The binary representation of 0.1 is: 0.00011001100110011001100110011001100110011001100110011... Again this is an infinite string represented in a finite amount of memory, so 0.1 is not exact. That's why you get this behavior: (loop [i 1 x 0.1] (prn (format %d %s %s i (str x) (str (* i 0.1 (when-not (= i 10) (recur (inc i) (+ x 0.1 1 0.1 0.1 2 0.2 0.2 3 0.30004 0.30004 4 0.4 0.4 5 0.5 0.5 6 0.6 0.6001 7 0.7 0.7001 8 0.7999 0.8 9 0.8999 0.9 10 0. 1.0 Apparently adding 0.1 6 times is
Re: r994 UTF8 addition broke latin-1 characters (ISO-8859-1) - WAS: Re: Unicode, accented characters
Some more information: In REPL, everything seems fine: exmentis= ààà ààà exmentis= (def a ) #'exmentis/a exmentis= a exmentis= (println a) nil exmentis= (. System/out println a) nil However, when I import a Java class: public class Application { public static final String abc = àààèèè; ... user= (import '(application Application)) nil user= Application/abc αααΦΦΦ So there is something more to the problem than what I said above... I tried (blindly) modifying other places that used UTF8 to use the default encoding. It didn't change anything. My time is up for tonight! ;( Any help would be appreciated. Thanks, Max On Mar 6, 9:34 pm, max3000 maxime.lar...@gmail.com wrote: There is definitely a bug. In r994 (Aug 07, 2008) UTF8 encoding was added to *in*, *out* and *err*. This messes up the Repl (and the Reader in general) as discussed above. Case in point, everything works fine when I go in the code and modify RT.java as follows: final static public Var OUT = Var.intern(CLOJURE_NS, Symbol.create(*out*), new OutputStreamWriter (System.out)); //, UTF8)); final static public Var IN = Var.intern(CLOJURE_NS, Symbol.create(*in*), new LineNumberingPushbackReader(new InputStreamReader (System.in))); //, UTF8))); (UTF8 commented out) Anyway this could be seen as a bug? Should I report it? Was this made like this for a reason? Thanks, Max On Mar 6, 8:03 pm, rzeze...@gmail.com rzeze...@gmail.com wrote: On Mar 6, 5:58 pm, max3000 maxime.lar...@gmail.com wrote: I don't really want to use the SVN version because I'm developing an application and can really do without the (normal) instabilities that come with development builds. FYI, you may want to consider using SVN for now because there have been breaking changes[1] since the last release. The general consensus seems to be that breaking changes are allowed until version 1.0 is released. Most of the commits are bug fixes, so IMO it only gets more stable, not less. 1:http://clojure.org/lazier --~--~-~--~~~---~--~~ 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: float vs fraction (just playing around)
Thanks for the very detailed explanation and all of the code examples. I was a bit twiddler a long time ago. (I enjoyed reading the opcodes in the mainframe dumps) Lisp is a new language. And, I think it counts as the Language of theYear, since it is so different than Java. I was playing with java.util.Date and range, by converting to number with .getTime. I couldn't figure out how to create a Date. I finally re-read the Date constructor and realized I had to coerce the number to a long. The compiler/ interpreter was telling me the truth. There wasn't a Date constructor for number. I was also playing with with-precision and rounding. On Mar 6, 9:06 pm, David Sletten da...@bosatsu.net wrote: On Mar 5, 2009, at 8:00 PM, mike.farn...@gmail.com wrote: I thought it neat that clojure supports fractions (just like Smalltalk). user= (/ 3) 1/3 I was sort of surprised by this. user= (+ (float (* (/ 2) (/ 3))) (float (* (/ 2) (/ 3))) ) 0.3334 It comes as no surprise that certain numbers cannot be represented by a finite string of decimal digits. We all realize that 1/3 = 0...., and the ... part is critical. Take it away and the equality goes away too. In other words, if that string of 3's stops, then we don't have 1/3 anymore. This situation is true inside the computer too. The floating-point representation of 1/3 is binary 0.01010101010101... Whereas in decimal we have 1/3 = 3*1/10 + 3*1/100 + 3*1/1000 + ..., in binary we have 1/3 = 0*1/2 + 1*1/4 + 0*1/8 + 1*1/16 + ... If this sum stops we once again lose equality. However, the computer only has finite memory in which to represent a floating-point number, so the string of 01s does in fact stop. The computer cannot represent 1/3 exactly in floating-point. Suppose for the sake of argument that the computer only stores the equivalent of 4 decimal digits. So we get 1/3 - 0.. But the true value is 0. 1/3 0.3334. In terms of the binary representation, depending on how many bits are used the decimal representation may be slightly closer to 0.3334 rather than 0.. You saw that by using the float function, which coerces the Ratio 1/3 to a single-precision float: (float 1/3) = 0.3334 If you had coerced to a double-precision float you would have seen this: (double 1/3) = 0. Neither one of these is more correct per se (the double is more precise of course). They simply reflect the limitations of different finite representations of 1/3. You can explore on your own by using Clojure's rationalize function (which as far as I can tell mirrors Common Lisp's RATIONAL function rather than its RATIONALIZE function): (rationalize (float 1/3)) = 41679084301/1250 (rationalize (double 1/3)) = /1 How close are these to the true values? (- (rationalize (float 1/3)) 1/3) = 37252903/3750 (- 1/3 (rationalize (double 1/3))) = 1/3 So the single-precision representation is slightly more than 1/3, which is why you see the terminal 4. Here's a little program to help you look inside 1/3. Just type (dec2bin/display-one-third PRECISION) where PRECISION is either float or double (you will need to widen your terminal window): (ns dec2bin (:use clojure.contrib.math)) (defn integer-to-binary [i] (if (zero? i) 0 (loop [i i result ] (if (zero? i) (apply str result) (recur (quot i 2) (if (zero? (rem i 2)) (cons \0 result) (cons \1 result ))) (defn fraction-to-binary [x digits] (loop [n digits fraction x result ] (if (zero? n) (apply str (reverse result)) (let [whole (quot (* 2 fraction) 1) fraction (rem (* 2 fraction) 1)] (recur (dec n) fraction (cons (char (+ whole (int \0))) result )) (defn decimal-to-binary ([x] (decimal-to-binary x 10)) ([x digits] (let [whole (integer-to-binary (quot x 1)) fraction (fraction-to-binary (rem x 1) digits)] (format %s.%s whole fraction (defn display-one-third [f] (prn (format %5s %-20s %-40s %s bits floating-point fraction binary)) (let [precision (if (= f float) 16 32)] (dotimes [i precision] (let [j (inc i) sum (reduce + (map #(/ (expt 2 (* 2 %))) (range 1 (inc j] (prn (format %5d %-20s %-40s %s (* 2 j) (str (f sum)) (str sum) (decimal-to-binary sum (* 2 j (= (+ (float (* (/ 2) (/ 3))) (float (* (/ 2) (/ 3))) ) (/ 3) ) yields true You have to be very careful comparing floating-point numbers. While the above discussion of 1/3 should not be surprising, many people do get surprised when they look at other numbers in floating-point. A perfect example is 0.1. In decimal, this looks like a nice fraction that
let vs. let*
I see a lot of let* in macro expansions, but Clojure's let already behaves like Common Lisp's LET*. Is let* archaic? It seems to behave the same as let in terms of sequential binding. (let [x 8 y (inc x)] (list x y)) = (8 9) (let* [x 8 y (inc x)] (list x y)) = (8 9) Aloha, David Sletten --~--~-~--~~~---~--~~ 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: What is Clojure NOT good for?
Excuse my ignorance but these expressions occasionally and not wise together are just opaque to me. If my desktop was crawling because of the load, I might understand the goal of manually managing services but it's not the case at all. Services not used are simply swapped if the system needs physical memory. Here it's obviously not the case... Can you be more precise about your thoughts ? Personally I consider my time invaluable, starting/stopping services on demand is not a good use of my time. Hardware does not resent fatigue and is much more powerful these days so why not ask it to save us time and pain ? BTW our internal git repositories (hosted on an XServer) respond pretty fast on our gigabit LAN :))) but not as fast a starting a REPL :))) Luc On Fri, 2009-03-06 at 14:50 -0800, Phil Hagelberg wrote: Luc Prefontaine lprefonta...@softaddicts.ca writes: I work with Ubuntu and all my frequently used tools are copied to RAM (/tmpfs) at boot time. My Java environment is there, Clojure, Eclipse, frequently used librairies... On top of that there's a daemon running to spot my frequently accessed files and serve them from RAM transparently. It takes me less than 1.3 secs to get the REPL prompt. That's great for a REPL, but if it took me that long to get (for example) git diff to return, it would be *really* annoying. If it's a tool you use occasionally, keeping a server running all the time may not be an wise solution. -Phil -- Luc Préfontaine Off.:(514) 993-0320 Fax.:(514) 993-0325 Armageddon was yesterday, today we have a real 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: let vs. let*
let* is an an internal implementation detail that supports the special form let. let* does no destructuring. --Steve On Mar 7, 2009, at 12:49 AM, David Sletten da...@bosatsu.net wrote: I see a lot of let* in macro expansions, but Clojure's let already behaves like Common Lisp's LET*. Is let* archaic? It seems to behave the same as let in terms of sequential binding. (let [x 8 y (inc x)] (list x y)) = (8 9) (let* [x 8 y (inc x)] (list x y)) = (8 9) Aloha, David Sletten --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
hash-map based on identity
Is there a variation of hash-map which supports comparison of keys using identical? rather than = ? Ditto with sets. --~--~-~--~~~---~--~~ 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 infinite loop
On Mar 6, 5:58 pm, Chouser chou...@gmail.com wrote: This registers the current thread to be stopped next time an INT signal is recieved, which happens when the user presses Ctrl-C. Try this: user= (Thread/sleep 1) Then press Ctrl-C before the 10 seconds are up, and you'll see: java.lang.Exception: SIGINT (NO_SOURCE_FILE:0) user= ...and you're back at the repl so you can try something else. This works for busy loops and should work for IO and other blocking behavior. Thanks for this - I just added it to my user.clj and now my reflexive Ctrl-C Ctrl-C in slime to break runaway functions no longer kills the clojure repl. Very nice. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---