Re: clojure-test-mode
Did you ever figure out what was causing this? I'm on clojure-mode 1.11.2 with Clojure 1.3. When I run clojure-test-run-tests from within emacs, I see error in process filter: Invalid read syntax: # in the status mini buffer. The tests do seem to run ok but I'm curious what is going on. On 19 June 2011 14:59, Gregg Reynolds d...@mobileink.com wrote: Hi folks, I somehow managed to get clojure-test-mode working, so I can execute C-c C-, from a test file and see the test results in the slime repl. However, in the mini-buffer I get the following message: error in process filter: Invalid read syntax: # Any idea what that means? It doesn't seem to prevent C-c C-, from working, but I'd like to fix it. Thanks, Gregg -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
How to :use a defrecord from another source file and namespace?
I'm having trouble writing code in one namespace that instantiates a type that is defined in another namespace. I have two source files: other.clj defines a function called my-fn and a type called huss: (ns my-project.other) (defrecord huss [x y z]) (defn my-fn [] (println my-fn)) core.clj can successfully call my-fn from the other file but I try to instantiate huss and I get an ClassNotFoundException (ns my-project.core (:use [my-project.other])) (my-fn) ; doesn't work... gives java.lang.IllegalArgumentException: Unable to resolve classname: huss (println (huss. 1 2 3)) What's the reason for this? Is it intended to work like this and what can I do in order to define a type in one source file (and namespace) and use it in another? Cheers, Chris -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Problem reloading source file with imports
Thanks Robert. That makes a lot of sense and I was able to follow your advice last night and get my source file to reload successfully by adding :only [indexed] to my :use clause (because indexed was the only function that I was using in this case). The thing that still confuses me is that I can successfully load a source file that imports the whole of clojure.contrib.seq once (with warnings) but an attempt to reload that source file then fails - even if I edit the source file to remove the whole :use clause before reloading. That's weird but I'm working again and that's the important thing - thanks. On 30 August 2010 21:05, Robert McIntyre r...@mit.edu wrote: Sorry, I was tired and didn't explain very well. Right now you have a naked (:use clojure.contrib.seq-utils) somewhere. You want to use partition-by, but that's already in core, so you might just get rid of the :use altogether. But maybe there are some other functions in seq-utils that you do want to use --- in that case, do (:use [clojure.contrib [seq-utils :only [functions you want]]]) or (:use [clojure.contrib [seq-utils :only []]]) to avoid stepping on core and also to document what you actually use. If you really want the seq-utils version of partition-by, then you can do: (:use [clojure.contrib [seq-utils :as whatever]]) whatever/partition-by And if you really want to replace the core version with the seq version without any namespacing, do (:refer-clojure :exclude [partition-by]) (:use [clojure.contrib [seq-utils :only [partition-by]]]) does that help? --Robert McIntyre On Mon, Aug 30, 2010 at 2:43 PM, Chris Jenkins cdpjenk...@gmail.com wrote: How would using the :only keyword help here? Just to be clear, the problem here is that attempting to load my source file the second time fails (loading the first time having succeeded, albeit with a few warnings about replacing symbols from clojure.core), which makes it very difficult for me to use swank-clojure, for example, because I can't hit C-c C-k twice on the same file. Here is the failure when I try to load the file for the second time: java.lang.IllegalStateException: partition-by already refers to: #'clojure.contrib.seq-utils/partition-by in namespace: test.core (core.clj:1) So here's my main question: If I'm working in the REPL and I edit a file that I've preu'vviously loaded, how can I cause the file to be reloaded without hitting that error? If my .clj file doesn't :use any other clojure modules then reloading works fine but, if it imports anything, then the second (load-file...) fails. On 30 August 2010 11:05, Robert McIntyre r...@mit.edu wrote: Yeah, they changed that from clojure 1.1 and it's really annoying --- as far as I know, your only options right now are to either select exactly which functions from seq-utils you want using the :only keyword, or if you really want to use the seq-utils version you can use refer-clojure and the :exclude keyword. Or, you can use the :as keyword in the :use form to qualify the import so that you don't actually replace anything. If you accidently get this warning and don't want to restart the repl you can do (ns-unmap 'your-namespace 'offending-function), fix the naked import, and reload. --Robert McIntyre On Mon, Aug 30, 2010 at 5:54 AM, Chris Jenkins cdpjenk...@gmail.com wrote: Since I switched to Clojure 1.2, I see an error message whenever I try to reload a source file that imports anything. The error message is of the form already refers to xxx, as though it is complaining that it can't import the same thing twice. For example, I have a minimal source file that looks like this: (ns test.core (:use clojure.contrib.seq-utils)) I can load it (once!) into the Clojure REPL successfully: $ java -cp lib/clojure-contrib-1.2.0.jar:lib/clojure-1.2.0.jar clojure.main Clojure 1.2.0 user= (load-file src/test/core.clj) WARNING: partition-by already refers to: #'clojure.core/partition-by in namespace: test.core, being replaced by: #'clojure.contrib.seq-utils/partition-by WARNING: frequencies already refers to: #'clojure.core/frequencies in namespace: test.core, being replaced by: #'clojure.contrib.seq-utils/frequencies WARNING: shuffle already refers to: #'clojure.core/shuffle in namespace: test.core, being replaced by: #'clojure.contrib.seq-utils/shuffle WARNING: reductions already refers to: #'clojure.core/reductions in namespace: test.core, being replaced by: #'clojure.contrib.seq-utils/reductions WARNING: partition-all already refers to: #'clojure.core/partition-all in namespace: test.core, being replaced by: #'clojure.contrib.seq-utils/partition-all WARNING: group-by already refers to: #'clojure.core/group-by in namespace: test.core, being replaced by: #'clojure.contrib.seq-utils/group-by WARNING: flatten already refers
Problem reloading source file with imports
Since I switched to Clojure 1.2, I see an error message whenever I try to reload a source file that imports anything. The error message is of the form already refers to xxx, as though it is complaining that it can't import the same thing twice. For example, I have a minimal source file that looks like this: (ns test.core (:use clojure.contrib.seq-utils)) I can load it (once!) into the Clojure REPL successfully: $ java -cp lib/clojure-contrib-1.2.0.jar:lib/clojure-1.2.0.jar clojure.main Clojure 1.2.0 user= (load-file src/test/core.clj) WARNING: partition-by already refers to: #'clojure.core/partition-by in namespace: test.core, being replaced by: #'clojure.contrib.seq-utils/partition-by WARNING: frequencies already refers to: #'clojure.core/frequencies in namespace: test.core, being replaced by: #'clojure.contrib.seq-utils/frequencies WARNING: shuffle already refers to: #'clojure.core/shuffle in namespace: test.core, being replaced by: #'clojure.contrib.seq-utils/shuffle WARNING: reductions already refers to: #'clojure.core/reductions in namespace: test.core, being replaced by: #'clojure.contrib.seq-utils/reductions WARNING: partition-all already refers to: #'clojure.core/partition-all in namespace: test.core, being replaced by: #'clojure.contrib.seq-utils/partition-all WARNING: group-by already refers to: #'clojure.core/group-by in namespace: test.core, being replaced by: #'clojure.contrib.seq-utils/group-by WARNING: flatten already refers to: #'clojure.core/flatten in namespace: test.core, being replaced by: #'clojure.contrib.seq-utils/flatten nil If I try to reload it then I see an error message: user= (load-file src/test/core.clj) java.lang.IllegalStateException: partition-by already refers to: #'clojure.contrib.seq-utils/partition-by in namespace: test.core (core.clj:1) user= This error message is seen even if I edit the source file and remove the (:use ...) clause and then try to load the file again. Anyone have any idea what is going on? I didn't see this behaviour in Clojure 1.1 and it would be nice if I could find a way to reload files that I'm working on. Cheers, Chris -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Problem reloading source file with imports
How would using the :only keyword help here? Just to be clear, the problem here is that attempting to load my source file the second time fails (loading the first time having succeeded, albeit with a few warnings about replacing symbols from clojure.core), which makes it very difficult for me to use swank-clojure, for example, because I can't hit C-c C-k twice on the same file. Here is the failure when I try to load the file for the second time: java.lang.IllegalStateException: partition-by already refers to: #'clojure.contrib.seq-utils/partition-by in namespace: test.core (core.clj:1) So here's my main question: If I'm working in the REPL and I edit a file that I've previously loaded, how can I cause the file to be reloaded without hitting that error? If my .clj file doesn't :use any other clojure modules then reloading works fine but, if it imports anything, then the second (load-file...) fails. On 30 August 2010 11:05, Robert McIntyre r...@mit.edu wrote: Yeah, they changed that from clojure 1.1 and it's really annoying --- as far as I know, your only options right now are to either select exactly which functions from seq-utils you want using the :only keyword, or if you really want to use the seq-utils version you can use refer-clojure and the :exclude keyword. Or, you can use the :as keyword in the :use form to qualify the import so that you don't actually replace anything. If you accidently get this warning and don't want to restart the repl you can do (ns-unmap 'your-namespace 'offending-function), fix the naked import, and reload. --Robert McIntyre On Mon, Aug 30, 2010 at 5:54 AM, Chris Jenkins cdpjenk...@gmail.com wrote: Since I switched to Clojure 1.2, I see an error message whenever I try to reload a source file that imports anything. The error message is of the form already refers to xxx, as though it is complaining that it can't import the same thing twice. For example, I have a minimal source file that looks like this: (ns test.core (:use clojure.contrib.seq-utils)) I can load it (once!) into the Clojure REPL successfully: $ java -cp lib/clojure-contrib-1.2.0.jar:lib/clojure-1.2.0.jar clojure.main Clojure 1.2.0 user= (load-file src/test/core.clj) WARNING: partition-by already refers to: #'clojure.core/partition-by in namespace: test.core, being replaced by: #'clojure.contrib.seq-utils/partition-by WARNING: frequencies already refers to: #'clojure.core/frequencies in namespace: test.core, being replaced by: #'clojure.contrib.seq-utils/frequencies WARNING: shuffle already refers to: #'clojure.core/shuffle in namespace: test.core, being replaced by: #'clojure.contrib.seq-utils/shuffle WARNING: reductions already refers to: #'clojure.core/reductions in namespace: test.core, being replaced by: #'clojure.contrib.seq-utils/reductions WARNING: partition-all already refers to: #'clojure.core/partition-all in namespace: test.core, being replaced by: #'clojure.contrib.seq-utils/partition-all WARNING: group-by already refers to: #'clojure.core/group-by in namespace: test.core, being replaced by: #'clojure.contrib.seq-utils/group-by WARNING: flatten already refers to: #'clojure.core/flatten in namespace: test.core, being replaced by: #'clojure.contrib.seq-utils/flatten nil If I try to reload it then I see an error message: user= (load-file src/test/core.clj) java.lang.IllegalStateException: partition-by already refers to: #'clojure.contrib.seq-utils/partition-by in namespace: test.core (core.clj:1) user= This error message is seen even if I edit the source file and remove the (:use ...) clause and then try to load the file again. Anyone have any idea what is going on? I didn't see this behaviour in Clojure 1.1 and it would be nice if I could find a way to reload files that I'm working on. Cheers, Chris -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts
Re: Problem reloading source file with imports
Thanks for the pointers you guys. I changed my code to this: (ns test.core (:use [clojure.contrib.seq :only (indexed)])) ... (indexed being the function that I was interested in) and it now works ok. I can reload the file as many times as I like. I must confess that I am rather confused by all this. When I was loading in the whole of clojure.contrib.seq-utils, it was perfectly possible to load partition-by once (albeit with a warning) but trying to reload the source file, causing partition-by to be loaded a second time, failed. Does that sound right? Cheers, Chris On 30 August 2010 20:31, Phil Hagelberg p...@hagelb.org wrote: On Mon, Aug 30, 2010 at 3:05 AM, Robert McIntyre r...@mit.edu wrote: Yeah, they changed that from clojure 1.1 and it's really annoying --- as far as I know, your only options right now are to either select exactly which functions from seq-utils you want using the :only keyword, or if you really want to use the seq-utils version you can use refer-clojure and the :exclude keyword. Or, you can use the :as keyword in the :use form to qualify the import so that you don't actually replace anything. Actually this namespace was only kept around for backwards-compatibility. If you use the new clojure.contrib.seq namespace it won't have these issues. Unfortunately while Clojure itself had a nice set of release notes documenting these changes, I couldn't find one for contrib. -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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure Web Programming group?
Great idea. I'm trying to figure out web development in Clojure atm and a group to specifically talk about this area would be great. On 18 August 2010 11:20, Shantanu Kumar kumar.shant...@gmail.com wrote: +1 Neat idea. Starting a Google group Clojure web development might be a solution. Regards, Shantanu On Aug 18, 2:05 am, Rasmus Svensson r...@lysator.liu.se wrote: I think there's a lot of questions that a Clojure programmer faces when doing web programming, not only regarding how the libraries work, but also regarding how to design a larger-than-trivial web applications. A mail list would be a very good way to be able to ask for advice or to be inspired by solutions other people have come up with. I think there is a lack of articles and blog posts on the web where people write about the experiences they had during the development of their web applications. I always get the feeling that what I am struggling with, some else has already struggled with too and maybe even solved. During the time I've done web development, I've been searching for something like this. // Rasmus -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Testing to see if an object is an element of a sequence
Hi, Is there a standard function to test to see if an object is an element of a sequence? I'm looking for an equivalent of Haskell's elem function. I wrote my own (badly)... (defn elem? [obj l] (if (empty? l) false (if (= obj (first l)) true (elem? obj (rest l) ...but it strikes me that there must be a standard function to do this. Cheers, Chris -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en To unsubscribe, reply using remove me as the subject.
Re: Testing to see if an object is an element of a sequence
Thanks guys :-). I didn't know about some and includes?. On 4/13/10, Stuart Halloway stuart.hallo...@gmail.com wrote: Hi Chris, includes? is in clojure.contrib.seq. Note that it runs in linear time. This will feature prominently in the FAQ when I update it. :-) Stu Hi, Is there a standard function to test to see if an object is an element of a sequence? I'm looking for an equivalent of Haskell's elem function. I wrote my own (badly)... (defn elem? [obj l] (if (empty? l) false (if (= obj (first l)) true (elem? obj (rest l) ...but it strikes me that there must be a standard function to do this. Cheers, Chris -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en To unsubscribe, reply using remove me as the subject. -- Sent from my mobile device -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: browsing clojure source code
If you can get emacs working with swank-clojure (I followed the instructions here http://github.com/jochu/swank-clojure to get it working on Emacs 23 on Linux) then you can interact with the running Clojure process. All you need to do is move the cursor over the symbol of interest and hit ALT-. to go to the definition of a symbol, or ATL-, to go back to where you were. On 23 February 2010 18:32, Paul Tarvydas tarvy...@visualframeworksinc.comwrote: I'm from the lisp world, not the java (nor eclipse) world, so I don't know what's available... Can anyone suggest how best to browse the source code for clojure? I've downloaded the clojure-read-only tree and would like to bounce around in it using something like find-tag. How does one create an emacs tags file for java and clojure, or, how does one load it into eclipse so that eclipse groks where everything is? thanks pt -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Best way to cause compilation failure?
Hi, What's the best way to force compilation to fail? For example, what if invalid arguments are passed into a macro? (throw (InvalidArgumentException.)) seems to do the trick. Is this the best way to do it? Cheers, Chris -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Suggest slime-redirect-inferior-output be default for Swank clojure
Seconded. I found this very confusing when I first started with Clojure. 2010/1/21 Alex Stoddard alexander.stodd...@gmail.com Hello, As detailed in Bradford Cross' blog, (http:// measuringmeasures.blogspot.com/2010/01/agony-of-clojurehadoop-logging- and-how.html) the rebinding of *out* done in the swank/slime repl can be very confusing to folk who don't already know slime. This is because so many java libraries output to stdout. And within Clojure it is very easy to have output happening on a different threads where *out* is still bound stdout which all goes to the *inferior-lisp* buffer (usually hidden) not the repl. The helpful advice given in comments on the blog post is to use slime- redirect-inferior-output. With that all stdout ends up in the repl buffer. A direct result of all the effort to make it very easy to get up and running with emacs/slime/swank/clojure is that many folk inexperienced with slime will be encountering it for the first time using clojure (like me for instance). Might I suggest that slime-redirect-inferior-output be the default for swank-clojure-project? That is much less surprising to newbies who don't yet know about *out*, thread bindings, and swank/slime's rebinding of *out* in the clojure repl. Thanks, Alex Stoddard -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure Box 1.1
Shawn, Mark, Thanks for the suggestions. I am definitely running as an Administrator and I don't have a .clojure dir in my home directory. The problem definitely seems to be the IBM JVM (on Windows) refusing to load an AOT compiled class in clojure-contrib. I'll investigate further when I get the chance. Cheers, Chris 2010/1/11 Shawn Hoover shawn.hoo...@gmail.com On Mon, Jan 11, 2010 at 3:49 PM, Chris Jenkins cdpjenk...@gmail.comwrote: Out of curiosity, what configuration do you have in place that's causing clojure.contrib.pprint to be loaded? I'm not sure - all I did was to install Clojure Box and then I immediately saw the error message when it started up. Do you know how I could learn more about the configuration? Cheers, Chris I see you got it working. I was about to say I was thinking of user.clj, which Clojure loads if you have one in a directory that is on the classpath. Also, if you have jars in $HOME/.clojure they are added to the classpath by swank-clojure and then .clojure is searched for user.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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Clojure Box 1.1
Hi, I downloaded Clojure Box 1.1 from here http://clojure.bighugh.com/, installed it and tried running it on Windows XP. Emacs starts ok and I get an *inferior-lisp* buffer but I see the following error message: user= user= java.lang.Exception: No such var: swank.swank/ignore-protocol-version (NO_SOURCE_FILE:3) user= user= nil java.lang.Exception: No such var: swank.swank/start-server (NO_SOURCE_FILE:5) I have googled around for the error message and seen a few situations where people had the wrong version of Clojure. However, I'm not really sure where to go next because I'm rather new to all this. Anyone have any idea how I could investigate and figure out what's up? Cheers, Chris PS: FYI here's the full text that I see in my *inferior-lisp* buffer: (require 'swank.swank) (swank.swank/ignore-protocol-version nil) (do (.. java.net.InetAddress getLocalHost getHostAddress) nil)(swank.swank/start-server c:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/slime.5668 :encoding iso-latin-1-unix) Clojure 1.1.0 user= java.lang.ClassFormatError: JVMCFRE114 field name is invalid; class=clojure/contrib/pprint/PrettyWriter, offset=0 (pprint.clj:6) user= user= java.lang.Exception: No such var: swank.swank/ignore-protocol-version (NO_SOURCE_FILE:3) user= user= nil java.lang.Exception: No such var: swank.swank/start-server (NO_SOURCE_FILE:5) user= user= -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure Box 1.1
Incidentally, I just tried Clojure Box 1.0 on the same machine and get exactly the same error message. Very odd. One thing that may be unusual about my setup is that I am using IBM JDK 1.6 (although I have managed to get Clojure + SLIME working on Linux using this JDK). Anyone have any ideas? 2010/1/11 Chris Jenkins cdpjenk...@gmail.com Hi, I downloaded Clojure Box 1.1 from here http://clojure.bighugh.com/, installed it and tried running it on Windows XP. Emacs starts ok and I get an *inferior-lisp* buffer but I see the following error message: user= user= java.lang.Exception: No such var: swank.swank/ignore-protocol-version (NO_SOURCE_FILE:3) user= user= nil java.lang.Exception: No such var: swank.swank/start-server (NO_SOURCE_FILE:5) I have googled around for the error message and seen a few situations where people had the wrong version of Clojure. However, I'm not really sure where to go next because I'm rather new to all this. Anyone have any idea how I could investigate and figure out what's up? Cheers, Chris PS: FYI here's the full text that I see in my *inferior-lisp* buffer: (require 'swank.swank) (swank.swank/ignore-protocol-version nil) (do (.. java.net.InetAddress getLocalHost getHostAddress) nil)(swank.swank/start-server c:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/slime.5668 :encoding iso-latin-1-unix) Clojure 1.1.0 user= java.lang.ClassFormatError: JVMCFRE114 field name is invalid; class=clojure/contrib/pprint/PrettyWriter, offset=0 (pprint.clj:6) user= user= java.lang.Exception: No such var: swank.swank/ignore-protocol-version (NO_SOURCE_FILE:3) user= user= nil java.lang.Exception: No such var: swank.swank/start-server (NO_SOURCE_FILE:5) user= user= -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure Box 1.1
Out of curiosity, what configuration do you have in place that's causing clojure.contrib.pprint to be loaded? I'm not sure - all I did was to install Clojure Box and then I immediately saw the error message when it started up. Do you know how I could learn more about the configuration? Cheers, Chris 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure Box 1.1
I have managed to get it to work now. The solution was to ensure that the Sun JRE was on the system PATH, rather than the IBM one. The IBM JRE seems to have a problem with the class file clojure/contrib/pprint/PrettyWriter.class in clojure-contrib.jar ...whereas the Sun one doesn't. The next question is, how can we find out why this is? There would appear to be two possibilities: 1) The IBM JVM is rejecting a valid class file 2) Clojure is emitting invalid bytecode that the Sun JVM doesn't mind but the IBM JVM rejects. 2010/1/11 Chris Jenkins cdpjenk...@gmail.com Incidentally, I just tried Clojure Box 1.0 on the same machine and get exactly the same error message. Very odd. One thing that may be unusual about my setup is that I am using IBM JDK 1.6 (although I have managed to get Clojure + SLIME working on Linux using this JDK). Anyone have any ideas? 2010/1/11 Chris Jenkins cdpjenk...@gmail.com Hi, I downloaded Clojure Box 1.1 from here http://clojure.bighugh.com/, installed it and tried running it on Windows XP. Emacs starts ok and I get an *inferior-lisp* buffer but I see the following error message: user= user= java.lang.Exception: No such var: swank.swank/ignore-protocol-version (NO_SOURCE_FILE:3) user= user= nil java.lang.Exception: No such var: swank.swank/start-server (NO_SOURCE_FILE:5) I have googled around for the error message and seen a few situations where people had the wrong version of Clojure. However, I'm not really sure where to go next because I'm rather new to all this. Anyone have any idea how I could investigate and figure out what's up? Cheers, Chris PS: FYI here's the full text that I see in my *inferior-lisp* buffer: (require 'swank.swank) (swank.swank/ignore-protocol-version nil) (do (.. java.net.InetAddress getLocalHost getHostAddress) nil)(swank.swank/start-server c:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/slime.5668 :encoding iso-latin-1-unix) Clojure 1.1.0 user= java.lang.ClassFormatError: JVMCFRE114 field name is invalid; class=clojure/contrib/pprint/PrettyWriter, offset=0 (pprint.clj:6) user= user= java.lang.Exception: No such var: swank.swank/ignore-protocol-version (NO_SOURCE_FILE:3) user= user= nil java.lang.Exception: No such var: swank.swank/start-server (NO_SOURCE_FILE:5) user= user= -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Trouble with running in jline editor. (newbie question)
Quick question: what operating system are you using? I would expect your command line to work fine on any *NIX platform. On Windows, you would need to replace the colon : with a semi colon ; 2010/1/10 piscesboy oraclmas...@gmail.com I placed clojure.jar, jline.jar and jline-0.9.94.jar all in the same directory. I started the default clojure editor using: java -cp clojure.jar clojure.main, and recieved the standard user= prompt. However, when using: java -cp jline-0.9.94.jar:clojure.jar jline.ConsoleRunner clojure.main I get: Exception in thread main java.lang.ClassNotFoundException: clojure.main at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:244) at java.lang.ClassLoader.loadClass(ClassLoader.java:315) at java.lang.ClassLoader.loadClass(ClassLoader.java:250) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:169) at jline.ConsoleRunner.main(ConsoleRunner.java:69) Am I using the wrong syntax? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: A Clojure Highlife
Cool - thanks. I didn't know about that function :-) 2009/11/27 John Harrop jharrop...@gmail.com On Thu, Nov 26, 2009 at 4:37 AM, Chris Jenkins cdpjenk...@gmail.comwrote: (defn flip-cell [b x y] (let [row (nth b y) cell (nth row x) new-cell (- 1 cell) new-row (assoc row x new-cell)] (assoc b y new-row))) (defn flip-cell [b x y] (update-in b [y x] #(- 1 %))) :) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: A Clojure Highlife
Thanks for sharing this. Coincidentally, I just wrote my first Clojure program which was... an implementation of Conway's Game of Life :-) I took a different approach - I represented the board as a vector of vectors of integers (1 for alive, 0 for dead) and then implemented a new-board function that takes a board as an argument and returns the next generation of that board. It seemed the functional way to do it. I then create an atom whose state is a grid and repeatedly call (swap! board new-board) in order to move it through the generations. I'll copy the source to my little program at the bottom of this email. If anyone has any comments on the style or possible improvements then I would be very interested to hear them. I'm particularly keen to hear how close to idiomatic Clojure style it is (is there a Clojure equivalent of the adjective Pythonic?) (import '(java.awt Color Graphics Dimension FlowLayout) '(javax.swing JPanel JFrame JButton Timer BoxLayout) '(java.awt.event MouseListener ActionListener ActionEvent)) (set! *warn-on-reflection* true) (def width 50) (def height 20) (def cell-width 10) (def cell-height 10) (def sleep-time 100) (def initial-board ; (apply vector (replicate height ; (apply vector (replicate width 0) [[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 1 1 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 1 1 0 1 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]]) (def board-atom (atom initial-board )) (def running-atom (atom false)) ;; Board manipulation functions (defn print-board [b] (doseq [row b] (println (str row (defn within [v min max] (and (= v min) ( v max))) (defn cell-at [b x y] (if (and (within x 0 width) (within y 0 height)) (nth (nth b y) x) 0)) (defn occurences [l item] (count (filter #(= % item) l))) (defn new-cell-value [cell neighbours] (let [num-1s (occurences neighbours 1)] (if (= cell 0) ; cell is currently dead and will become alive iff it has 3 living ; neighbours (if (= num-1s 3) 1 0) ; else cell is currently alive and will die iff it has fewer than 2 or ; more than 3 living neighbours (if (or ( num-1s 2) ( num-1s 3)) 0 1 (defn cell-neighbours [b x y] [(cell-at b (- x 1) (- y 1)) (cell-at b x (- y 1)) (cell-at b (+ x 1) (- y 1)) (cell-at b (- x 1) y) (cell-at b (+ x 1) y) (cell-at b (- x 1) (+ y 1)) (cell-at b x (+ y 1)) (cell-at b (+ x 1) (+ y 1))]) (defn new-value-at [b x y] (let [cell (cell-at b x y) neighbours (cell-neighbours b x y)] (new-cell-value cell neighbours))) (defn new-board [b] (vec (for [y (range height)] (vec (for [x (range width)] (new-value-at b x y)) (defn flip-cell [b x y] (let [row (nth b y) cell (nth row x) new-cell (- 1 cell) new-row (assoc row x new-cell)] (assoc b y new-row))) (defn apply-n-times [f n x] (if (zero? n) x (recur f (dec n) (f x ;; GUI functions (defn make-action-listener [f] (proxy [ActionListener] [] (actionPerformed [e] (f e (defn render [#^Graphics g b] (doseq [y (range height)]
Setting *warn-on-reflection* such that multiple threads can see it
Hi, Is it possible to set *warn-on-reflection* such that it can be seen by multiple threads? I can't use def to define *warn-on-reflection* because it is defined in another namespace. I can use set! to change the value of the binding for one thread but this is not seen by other threads: (set! *warn-on-reflection* true) (.start (Thread. #(println *warn-on-reflection*))) ...prints false The reason that I would like to do this is that I'm writing a program that uses Swing and I'd like to see if reflection is used on callbacks that execute on the AWT event thread... ideally without having to figure out how to make Swing call my function that sets *warn-on-reflection* before it does anything else. Cheers, Chris -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Setting *warn-on-reflection* such that multiple threads can see it
That's great - now why didn't I realise that :-) Thanks, Chris 2009/11/24 Christophe Grand christo...@cgrand.net Hi, On Tue, Nov 24, 2009 at 6:38 PM, Chris Jenkins cdpjenk...@gmail.comwrote: Is it possible to set *warn-on-reflection* such that it can be seen by multiple threads? I can't use def to define *warn-on-reflection* because it is defined in another namespace. I can use set! to change the value of the binding for one thread but this is not seen by other threads: (set! *warn-on-reflection* true) (.start (Thread. #(println *warn-on-reflection*))) ...prints false The reason that I would like to do this is that I'm writing a program that uses Swing and I'd like to see if reflection is used on callbacks that execute on the AWT event thread... ideally without having to figure out how to make Swing call my function that sets *warn-on-reflection* before it does anything else. *warn-on-reflection* is a compile-time flag, not a runtime flag so, unless you are using eval in the event thread, you don't need to care. Clojure outputs the warnings once: when you define the function. hth, Christophe -- Professional: http://cgrand.net/ (fr) On Clojure: http://clj-me.cgrand.net/ (en) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en