labrepl: kl...@feersum:~/projects/labrepl$ script/repl java.lang.ExceptionInInitializerError (control.clj:9)
leiningen reinstalled with self-install labrepl cloned and lein deps run without any hickups laprepl starts up with the following error and localhost:8080 does not respond kl...@feersum:~/projects/labrepl$ script/repl Clojure 1.2.0-master-SNAPSHOT java.lang.ExceptionInInitializerError (control.clj:9) user= In the irc log #clojure log - Apr 29 2010, palamas mentions the same problem at 1:30, but does not get any responses. Does anybody have a bright idea? /klang -- 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: what is wrong with (use `clojure.contrib.string) ?
On Apr 29, 10:43 pm, David Nolen dnolen.li...@gmail.com wrote: My rule of thumb is: use + :only require + :as (inc *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.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Beginner's question regarding implementing a constructor using gen-class
On 30/04/2010, at 3:46 PM, Gregg Williams wrote: Have you ever wanted to abandon a simple program with a bug that has been DRIVING YOU CRAZY because it's just got to be something SO simple, you'd be embarrassed to admit that you didn't see WHAT WAS STARING YOU IN THE FACE all along? Well, this is mine: (ns org.InfoML.genclassObject (:gen-class :extends [java.lang.Object] :extends java.lang.Object (or just extends Object, because java.lang.* is automatically imported) Antony Blakey - CTO, Linkuistics Pty Ltd Ph: 0438 840 787 There is nothing more difficult to plan, more doubtful of success, nor more dangerous to manage than the creation of a new order of things... Whenever his enemies have the ability to attack the innovator, they do so with the passion of partisans, while the others defend him sluggishly, So that the innovator and his party alike are vulnerable. -- Niccolo Machiavelli, 1513, The Prince. -- 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: Beginner's question regarding implementing a constructor using gen-class
Hi, On 30 Apr., 08:16, Gregg Williams greg...@innerpaths.net wrote: And what's with the slashes in [java/lang/Object]--I've never seen that before. Alex wrote you before: :extends does not take a vector. Ad your constructor question: see :post-init. Sincerely Meikel -- 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: Defining a namespace inside a let
Hello Armando, did you try the second half of you experiment in a clean REPL? As you describe it, the first evaluation may have created the var. Regards, alux On 29 Apr., 21:32, Armando Blancas armando_blan...@yahoo.com wrote: The REPL switches to the namespace ns-1 and the var my-namespace is in user ! I don't see that with CLJ 1.2 on Windows: user= (do (ns ns-1) (def my-namespace *ns*) my-namespace) #Namespace ns-1 ns-1= (ns user) nil user= (println (do (ns ns-1) (def my-namespace *ns*) my-namespace)) #Namespace ns-1 nil ns-1= (var my-namespace) #'ns-1/my-namespace -- 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
Re: what is wrong with (use `clojure.contrib.string) ?
On Apr 30, 2010, at 9:15 , ataggart wrote: On Apr 29, 10:43 pm, David Nolen dnolen.li...@gmail.com wrote: My rule of thumb is: use + :only require + :as (inc *1) (inc *1) (conj *2 Also use is handy for your own nameslaces, if you've a project that consists out of more then one to help you orderinging stuff but you actually need all the defined functions from 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 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: labrepl: kl...@feersum:~/projects/labrepl$ script/repl java.lang.ExceptionInInitializerError (control.clj:9)
klang karstenl...@gmail.com writes: laprepl starts up with the following error and localhost:8080 does not respond kl...@feersum:~/projects/labrepl$ script/repl Clojure 1.2.0-master-SNAPSHOT java.lang.ExceptionInInitializerError (control.clj:9) Looks like labrepl is not locked to a particular version of Clojure and so is using the very latest bleeding edge. Seems to be a conflict with some of the newly added functions and compojure. Hopefully Stuart will fix this soon, but in meantime you can just use a version of Clojure that's a few days old. To do this simply: 1. Edit labrepl/project.clj. Change the version for org.clojure/clojure from 1.2.0-master-SNAPSHOT to 1.2.0-master-20100422.180114-42 2. Remove the jar: $ rm lib/clojure-1.2.0-* 3. Download the selected version: $ lein deps 4. Try again running the repl again: $ script/repl Hopefully that should do the trick. -- 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: Does clojure.contrib.io.slurp work with binary files?
Ok great, thanks guys. Exactly what I needed. On Apr 30, 12:12 am, Alex Osborne a...@meshy.org wrote: Hi Matt, Matt Culbreth mattculbr...@gmail.com writes: I'm using slurp to read data from a file and send it to a stream, but sometimes that's failing. I've got a theory that it has to do with slurp not reading binary data correctly. Is that true? Do I need to go down to the lower level Java classes and build a byte array using InputFileStream and .read()? Yep, you're spot on. The problem is that slurp reads data as characters, not bytes, so they'll likely be interpreted as UTF-8 (depends on your locale settings unless you set it explicitly) which will mess them up if they're not actually UTF-8 characters. You should indeed use byte arrays or DataInputStream or ByteBuffer or similar (depending on what sort of manipulation you need to do) rather than strings when working with non-textual data. Note that c.c.duck-streams (now known as c.c.io) 'copy multimethod when given streams or byte arrays (not reader, writers or strings) will do the right thing. -- 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 athttp://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 1.2 seq fn enhancement FAQ
On Apr 29, 2010, at 4:21 AM, ataggart wrote: I know it won't matter, but for posterity if nothing else... Functions named contains-key? and contains-val? would make a lot more sense to me than the current contains? and new seq-contains?. Anyone looking at contains-val? should expect it to be O(n). The only effective difference would be that the test value for contains-val? is consistently a single value rather than a [key value] tuple for maps. I disagree. People don't consider sets, vectors, arrays or strings to have 'keys'. But, like maps, they all support fast lookup of some sort. Would contains-val? be fast for sets? As a user of sets, I consider them collections of values, and I absolutely would reach for contains- val? in any library that had it, for use with sets. If so, and I used contains-val?, and I moved code from using sets to maps (happens frequently), or vectors (also happens) my perf would suddenly stink. If not fast on sets, why not? The reason isn't supported by the name. The mismatch with the seq values of maps is also disconcerting for something that would purport to be sequential, as the things returned by (seq amap) are key+value pairs. Just because you wouldn't reach for contains? for use with a known vector doesn't mean your code, or other code built on the abstraction, won't end up calling it with a vector. And don't think you never use contains? on a vector/array - you rewrite it every time you write (if (and (= 0 i) ( i (count v))) ...) 'contains?' and 'get' abstract over fast lookup. They are polymorphic on the collection type and on the nature of the looked-up thing. For maps the looked-up thing is a key, for sets: a value, for vectors, strings and arrays: an index. Calling it contains-key? doesn't make them the same, nor add any value. In Clojure, 'contains?' is about 'get' succeeding. Nothing more or less. It is not a rummager. (if (contains? coll x) (get coll x) (plan-b)) Renaming contains? is not on the table. For people that understand its relationship with get, it makes perfect sense (and I don't think I'm the only one :). And there is a lot of client code. And no one has come up with a better name that doesn't include caveats. contains? is internally consistent, is unfamiliar. I do understand that this use of the word differs from that used in e.g., Java. But I'll make the same argument to Java devs that I do to the Lispers, who have seen many more of their prized words repurposed in Clojure (assoc, loop, do et al): The words can't mean the same thing forever without trapping us in the same semantics forever, and there are only so many good words. Everyone has to realize that this level of polymorphism in Clojure is unusual. I haven't seen a library with equivalents to get and contains?. Heck, in Java, Maps aren't even collections! So, should we adopt their nomenclature because it is familiar? I agree that contains?'s behavior on vectors is confusing for newcomers. That's not a reason for it to be different. And that people need a way to do that rummaging job. They of course can, with 'some'. But I also agree that 'some', being a higher-order function, would not necessarily be the tool newcomers would consider for the job of rummaging for a value. Perhaps it's a good first lesson, as they are not going to find filter-val etc either. So, I pulled in 'includes?' from contrib and renamed it seq-contains? The only options for right now are: A) I remove seq-contains? B) I rename seq-contains? I'm inclined towards A so we can all stop wasting time and energy on this unnecessary function. 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 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: Beginner's question regarding implementing a constructor using gen-class
simple, you'd be embarrassed to admit that you didn't see WHAT WAS STARING YOU IN THE FACE all along? Don't be too hard on yourself - it takes a while for the clojure patterns to sink in so you easily spot the simple errors. Best to throw it out there so someone else can help. Gen-class is a tricky place to be in the beginning as its syntax and operation is pretty complex. Coincidentally (as is so often the case with this forum), I have just been doing something pretty similar to yourself, so I thought I'd post it to give you (and others) a good example of interop with gen-class and how I've use it in this case... (ns timr.TimerTask (:import (java.util TimerTask)) (:gen-class :extends java.util.TimerTask :init init :constructors {[clojure.lang.Associative][]} :state ttmap)) (defn -init Note, throws a InvocationTargetException if anythong goes wrong. [#^clojure.lang.Associative mp] (let [ns-sym (get mp task-ns (str *ns*)) task-fn-nm (get mp task-fn-nm 'do-task) ns-sym (symbol ns-sym) task-ns (find-ns ns-sym) task-ns (if (nil? task-ns) (let [n (create-ns ns-sym)] (require ns-sym) n) task-ns) task-fn (get (ns-publics ns-sym) (symbol task-fn-nm)) ] [[] (assoc mp :task-ns task-ns :task-fn task-fn)])) (defn -run [this] (let [ttmap (.ttmap this)] ((ttmap :task-fn) ttmap))) The above compiles a clojure class extending java.util.TimerTask, but passing the ns name and run function name in a map to the constructor (java.util.Map or clojure Associative structure). When a TimerTask object is instantiated, it loads and requires (if necessary) the ns and determines which fn should be called in run() when the timer triggers the task. (Note that the ns defaults to the current ns and the task fn to do-task). Note that in this case I don't need to pass state from one invocation to the next, so I'm just storing a map in the state and not a ref as in Rich's example at clojure.org. From the repl... (import 'timr.TimerTask) (defn my-task [mp] (println Allo...)) def tt (TimerTask. {task-fn-nm my-task})) (doto (java.util.Timer.) (.schedule tt (long 1000) (long 3000))) Allo... Allo... Allo... So, I can create clojure timer tasks and instantiate them from both clojure and java, allowing me to easily bring clojure into legacy java apps with only this boiler-plate being AOT compiled. All my actual clojure tasks are just clj src files on the class path (makes builds simpler - clojure does all the work and I have only one compile... (binding [*compile-path* WEB-INF/classes] (compile 'timr.TimerTask)) I use a similar technique for extending HttpServlets, ContextListener (implementations), JSP-clojure bridges, etc, and dynamically invoking the clojure functions from the jave side and of course the clojure side! Hope that gives you some ideas and pointers. -Rgds, Adrian. On Fri, Apr 30, 2010 at 8:16 AM, Gregg Williams greg...@innerpaths.net wrote: Have you ever wanted to abandon a simple program with a bug that has been DRIVING YOU CRAZY because it's just got to be something SO simple, you'd be embarrassed to admit that you didn't see WHAT WAS STARING YOU IN THE FACE all along? Well, this is mine: (ns org.InfoML.genclassObject (:gen-class :extends [java.lang.Object] :init init :constructors {[] []} :state state)) (defn -init [s] [[] (ref foo)]) (defn -main [] (let [x (new org.InfoML.genclassObject)] (println x))) I'm beyond getting clues that will help me solve my original problem-- it just bothers me that I can't figure out what's happening. Whether I compile the org.InfoML package or not, I get the same error message: Exception in thread main java.lang.ClassNotFoundException: [java/ lang/Object] (genclassObject.clj:1) ... (a bunch of lines omitted here) ... Caused by: java.lang.ClassNotFoundException: [java/lang/Object] at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:247) at clojure.lang.RT.classForName(RT.java:1504) at clojure.core$the_class__7054.invoke(genclass.clj:91) at clojure.core$generate_class__7060.invoke(genclass.clj:99) at clojure.core$gen_class__7189.doInvoke(genclass.clj:593) at clojure.lang.RestFn.invoke(RestFn.java:761) at clojure.lang.Var.invoke(Var.java:421) at clojure.lang.AFn.applyToHelper(AFn.java:289) at clojure.lang.Var.applyTo(Var.java:476) at clojure.lang.Compiler.macroexpand1(Compiler.java:4504) at clojure.lang.Compiler.analyzeSeq(Compiler.java:4578) ... 34 more And what's with the slashes in [java/lang/Object]--I've never seen that before. I beg your forbearance in advance. Please, make the pain stop. PS to Mikel: Regarding my original goal, converting the GraphEditor.java program to Clojure, it should be obvious that my objective is not simply to get an example program running onscreen. Rather, I really
Re: clojure 1.2 seq fn enhancement FAQ
2010/4/30 Rich Hickey richhic...@gmail.com: On Apr 29, 2010, at 4:21 AM, ataggart wrote: I know it won't matter, but for posterity if nothing else... Functions named contains-key? and contains-val? would make a lot more sense to me than the current contains? and new seq-contains?. Anyone looking at contains-val? should expect it to be O(n). The only effective difference would be that the test value for contains-val? is consistently a single value rather than a [key value] tuple for maps. I disagree. People don't consider sets, vectors, arrays or strings to have 'keys'. But, like maps, they all support fast lookup of some sort. Would contains-val? be fast for sets? As a user of sets, I consider them collections of values, and I absolutely would reach for contains-val? in any library that had it, for use with sets. If so, and I used contains-val?, and I moved code from using sets to maps (happens frequently), or vectors (also happens) my perf would suddenly stink. If not fast on sets, why not? The reason isn't supported by the name. The mismatch with the seq values of maps is also disconcerting for something that would purport to be sequential, as the things returned by (seq amap) are key+value pairs. Just because you wouldn't reach for contains? for use with a known vector doesn't mean your code, or other code built on the abstraction, won't end up calling it with a vector. And don't think you never use contains? on a vector/array - you rewrite it every time you write (if (and (= 0 i) ( i (count v))) ...) 'contains?' and 'get' abstract over fast lookup. They are polymorphic on the collection type and on the nature of the looked-up thing. For maps the looked-up thing is a key, for sets: a value, for vectors, strings and arrays: an index. Calling it contains-key? doesn't make them the same, nor add any value. In Clojure, 'contains?' is about 'get' succeeding. Nothing more or less. It is not a rummager. While it sounds soo evident now that you say that explicitly ( the contains? / get pair ), it may be good to reflect that in the docs of the functions rather than just keep this knowledge here ? (if (contains? coll x) (get coll x) (plan-b)) Renaming contains? is not on the table. For people that understand its relationship with get, it makes perfect sense (and I don't think I'm the only one :). And there is a lot of client code. And no one has come up with a better name that doesn't include caveats. contains? is internally consistent, is unfamiliar. I do understand that this use of the word differs from that used in e.g., Java. But I'll make the same argument to Java devs that I do to the Lispers, who have seen many more of their prized words repurposed in Clojure (assoc, loop, do et al): The words can't mean the same thing forever without trapping us in the same semantics forever, and there are only so many good words. Everyone has to realize that this level of polymorphism in Clojure is unusual. I haven't seen a library with equivalents to get and contains?. Heck, in Java, Maps aren't even collections! So, should we adopt their nomenclature because it is familiar? I agree that contains?'s behavior on vectors is confusing for newcomers. That's not a reason for it to be different. And that people need a way to do that rummaging job. They of course can, with 'some'. But I also agree that 'some', being a higher-order function, would not necessarily be the tool newcomers would consider for the job of rummaging for a value. Perhaps it's a good first lesson, as they are not going to find filter-val etc either. So, I pulled in 'includes?' from contrib and renamed it seq-contains? The only options for right now are: A) I remove seq-contains? B) I rename seq-contains? I'm inclined towards A so we can all stop wasting time and energy on this unnecessary function. 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 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
Re: labrepl: kl...@feersum:~/projects/labrepl$ script/repl java.lang.ExceptionInInitializerError (control.clj:9)
I will check in a fix later this morning. Stu klang karstenl...@gmail.com writes: laprepl starts up with the following error and localhost:8080 does not respond kl...@feersum:~/projects/labrepl$ script/repl Clojure 1.2.0-master-SNAPSHOT java.lang.ExceptionInInitializerError (control.clj:9) Looks like labrepl is not locked to a particular version of Clojure and so is using the very latest bleeding edge. Seems to be a conflict with some of the newly added functions and compojure. Hopefully Stuart will fix this soon, but in meantime you can just use a version of Clojure that's a few days old. To do this simply: 1. Edit labrepl/project.clj. Change the version for org.clojure/clojure from 1.2.0-master-SNAPSHOT to 1.2.0-master-20100422.180114-42 2. Remove the jar: $ rm lib/clojure-1.2.0-* 3. Download the selected version: $ lein deps 4. Try again running the repl again: $ script/repl Hopefully that should do the trick. -- 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
Re: clojure 1.2 seq fn enhancement FAQ
On Apr 29, 2010, at 2:19 PM, MarkSwanson wrote: On Apr 29, 4:21 am, ataggart alex.tagg...@gmail.com wrote: I know it won't matter, but for posterity if nothing else... Functions named contains-key? and contains-val? would make a lot more sense to me than the current contains? and new seq-contains?. Anyone looking at contains-val? should expect it to be O(n). The only effective difference would be that the test value for contains-val? is consistently a single value rather than a [key value] tuple for maps. +1. This is super clear. I find nothing existing or proposed comes close to this level of clarity. inc. those are great names. --Steve -- 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 1.2 seq fn enhancement FAQ
Hi, On Thu, Apr 29, 2010 at 7:48 AM, Meikel Brandmeyer m...@kotka.de wrote: On 29 Apr., 01:38, Mark Engelberg mark.engelb...@gmail.com wrote: 1. Don't include seq-contains? The behavior you want can usually be achieved by using (some #{item} coll). Disadvantage - if you're testing to see if the collection contains nil, that won't work. Not entirely correct. (some #(= % item) coll) works always and is basically how seq-contains? is implemented. However there are opinions that some is not obvious enough. (some {item true} coll) works with nil too, but usally all the love goes to #(= % item, it's unfair! :-) Christophe -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com 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: Defining a namespace inside a let
In a clean repl: C:\repl Clojure 1.2.0-master-SNAPSHOT user= (println (do (ns ns-1) (def my-namespace *ns*) my-namespace)) #Namespace ns-1 nil ns-1= On Apr 30, 1:17 am, alux alu...@googlemail.com wrote: Hello Armando, did you try the second half of you experiment in a clean REPL? As you describe it, the first evaluation may have created the var. Regards, alux On 29 Apr., 21:32, Armando Blancas armando_blan...@yahoo.com wrote: The REPL switches to the namespace ns-1 and the var my-namespace is in user ! I don't see that with CLJ 1.2 on Windows: user= (do (ns ns-1) (def my-namespace *ns*) my-namespace) #Namespace ns-1 ns-1= (ns user) nil user= (println (do (ns ns-1) (def my-namespace *ns*) my-namespace)) #Namespace ns-1 nil ns-1= (var my-namespace) #'ns-1/my-namespace -- 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 athttp://groups.google.com/group/clojure?hl=en- Hide quoted text - - Show quoted text - -- 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
something stupid I'm trying to do
I'm pounding my head against the wall trying to understand how to do a simple task. What I want to do is write a function that will take a even-numbered set of numbers and split them into pairs. What I have right now is the following user (defn pairup ([a b] [a b])([a b rest] (cons (pairup a b) (apply pairup rest))) ([] [] )) #'user/pairup user (pairup 1 2 3 4 5 6 7 8) ([1 2] [3 4] [5 6] 7 8) user I can't get the last pair into a vector like the others. Can someone tell me what I am doing wrong? I know there is probably a way using the language to do this but I ended up trying to do it from scratch as a learning exercise. Thanks John -- 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: Problem with classpath (noob question)
Hello, I'm stuck with Programming Clojure on page 37 on a Windows 7 machine. After downloading the examples dir into C:/clojure, I typed: user (require 'examples.introduction) and I got ; Evaluation aborted. java.io.FileNotFoundException: Could not locate examples/ introduction__init.class or examples/introduction.clj on classpath: (NO_SOURCE_FILE:0) My .emacs file looks like this: (setq swank-clojure-extra-classpaths (list C:/Clojure)) The files in C:/Clojure are there (I triplechecked) Any help will be appreciated. -- 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
protocols metadata
Hi everyone, Reading the documentation I found that except for the docstring there is no way to tell that InternalReduce is a protocol, it's tagged simply as a var. Why don't add a :protocol true to the metadata for protocols like :macro true for macros? Andrea. -- 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: Newbie: Finding performance bottlenecks
I fixed my bottleneck-finding problem by applying the right jvisualvm parameters. You say: It's discouraged to use the mutable reference types in a fine-grained way like this. I would recommend changing your code to just be a vector of Clojure PersistentMaps that you map over. What do you mean by this? defstruct creates a struct-map which - as far as I know - is a persistentmap. And I do not use a vector because the amount of bodies that I map over varies - for example when the player destroys a monster ;) On Apr 23, 5:09 pm, David Nolen dnolen.li...@gmail.com wrote: In your code you have: (defstruct body :id :type ; :projectile or :unit - projectiles do not collide with other bodies; :current-position ; ref :current-cells ; ref :current-rotation ;atom :pixel-half-width :pixel-half-height :half-width :half-height :components) ; a map of (:comp-type comp) It's discouraged to use the mutable reference types in a fine-grained way like this. I would recommend changing your code to just be a vector of Clojure PersistentMaps that you map over. It seems that your program is not so dissimilar from something that I worked on, you might want to look at this code for some ideas how to improve the speed of your code:http://github.com/swannodette/flocking/blob/master/src/flocking/flock... When I first implemented this in early 2008 it was taking about 100-120ms to update 150 boids. This version can do it in about 6-8ms. I also note that you're not type-hinting your math, but I'm unsure how much that plays into the perf you're seeing. David On Fri, Apr 23, 2010 at 4:55 AM, msappler damnedmar...@web.de wrote: http://pastebin.com/Vv7xr6Uj -- 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 athttp://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
Fwd: clojure box: Problem with classpath (noob question)
Hello, yesterday, I sent my noob question about the classpath to the group. So far, my message has not shown up yet. Could you please post my message to the Clojure group? Thank you in advance. Kind regards, Rainer Wolf -- Forwarded message -- From: Rainer wolf.rai...@gmail.com Date: Fri, Apr 30, 2010 at 12:58 AM Subject: clojure box: Problem with classpath (noob question) To: Clojure clojure@googlegroups.com Hello, I'm stuck with Programming Clojure on page 37 on a Windows 7 machine. After downloading the examples dir into C:/clojure, I typed: user (require 'examples.introduction) and I got ; Evaluation aborted. java.io.FileNotFoundException: Could not locate examples/ introduction__init.class or examples/introduction.clj on classpath: (NO_SOURCE_FILE:0) My .emacs file looks like this: (setq swank-clojure-extra-classpaths (list C:/Clojure)) The files in C:/Clojure are there (I triplechecked) Any help will be appreciated. -- Rainer Wolf -- 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: Agents, eval, quasi-quote closures
Okay, found a fix do my own bug. You can use the with-ns namespace to solve this issue. I changed the form to be like this: (send test-result (fn [ args] (with-ns 'my-ns (eval `(- ~@(deref test-query)) FYI On Apr 29, 5:09 pm, Sean Devlin francoisdev...@gmail.com wrote: Right... Is there a way to force an agent thread to be evaluated in a certain namespace? You see, the current design accepts a string, and uses read-string to parse it. i.e. I call a form like this a lot (send test-query conj (read-string (get-input))) Sean On Apr 29, 4:40 pm, Laurent PETIT laurent.pe...@gmail.com wrote: Hello Sean, You want (def test-query (agent `[test-coll (take 2)])) to fully qualify test-coll (and also take, btw) because when passed to eval on the agent's thread, who knows to which value *ns* will be bound ? (tested on my machine) HTH, -- Laurent 2010/4/29 Sean Devlin francoisdev...@gmail.com: I'm having a lot of trouble getting an app to work. I'm using agents in a GUI app. For the sake of discussion I've got the following things defined: (def test-coll [{:a 1 :b 2 :c 3} {:a 4 :b 5 :c 6} {:a 7 :b 8 :c 9} {:a 10 :b 11 :c 12} ]) (def test-query (agent '[test-coll (take 2)])) (def test-result (agent [])) I want to execute test-query like so: user= (eval `(- ~@(deref test-query))) ({:a 1, :b 2, :c 3} {:a 4, :b 5, :c 6}) This part works at the REPL fine. Next I wrap it in a closure: user= ((fn [ args] (eval `(- ~@(deref test-query) ({:a 1, :b 2, :c 3} {:a 4, :b 5, :c 6}) Also fine. Now, I want to send this to the agent test-result user= (send test-result (fn [ args](eval `(- ~@(deref test- query) #Agent (...) user= @test-result #CompilerException java.lang.Exception: Agent has errors (NO_SOURCE_FILE:468) user= (agent-errors test-result) (#CompilerException java.lang.Exception: Unable to resolve symbol: test-coll in this context (NO_SOURCE_FILE:459)) Blargh. Why doesn't this work when I use send? I'm at a loss here. Sean -- 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 athttp://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 athttp://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: something stupid I'm trying to do
I think you want this: (defn pairup [a b rest] (cons [a b] (if rest (apply pairup rest) []))) On Thu, Apr 29, 2010 at 3:32 PM, john.holland jbholl...@gmail.com wrote: I'm pounding my head against the wall trying to understand how to do a simple task. What I want to do is write a function that will take a even-numbered set of numbers and split them into pairs. What I have right now is the following user (defn pairup ([a b] [a b])([a b rest] (cons (pairup a b) (apply pairup rest))) ([] [] )) #'user/pairup user (pairup 1 2 3 4 5 6 7 8) ([1 2] [3 4] [5 6] 7 8) user I can't get the last pair into a vector like the others. Can someone tell me what I am doing wrong? I know there is probably a way using the language to do this but I ended up trying to do it from scratch as a learning exercise. Thanks John -- 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 -- Mark J. Reed markjr...@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 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: what is wrong with (use `clojure.contrib.string) ?
On Apr 30, 1:43 am, David Nolen dnolen.li...@gmail.com wrote: My rule of thumb is: use + :only require + :as Yes. clojure.contrib.string deliberately has short function names, which means there is some overlap with clojure.core. Note: (use '[clojure.contrib.string :as st :only ()]) also works. -SS -- 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: Defining a namespace inside a let
ns and in-ns have special evaluation rules. In general, they don't work as you'd expect in block expressions such as do or let. If you want to create namespaces programatically, use create-ns and intern. -SS On Apr 26, 6:25 pm, David McNeil mcneil.da...@gmail.com wrote: I am experimenting with clojure.test and I encountered the following situation which I cannot explain. This code: (println (do (ns ns01 (:use clojure.test)) (deftest test1 nil) (run-tests))) Produces the expected result (note: it runs one test): Testing ns01 Ran 1 tests containing 0 assertions. 0 failures, 0 errors. {:type :summary, :test 1, :pass 0, :fail 0, :error 0} However, if I do the exact same thing inside of a let: (println (let [] (do (ns ns02 (:use clojure.test)) (deftest test1 nil) (run-tests Then I get the unexpected result that no tests are executed: Testing ns02 Ran 0 tests containing 0 assertions. 0 failures, 0 errors. {:type :summary, :test 0, :pass 0, :fail 0, :error 0} Seems there is something going on with namespaces that I do not understand and I hope that somewhere here can explain it. Thank you. -David McNeil -- 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 athttp://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 1.2 seq fn enhancement FAQ
On Fri, Apr 30, 2010 at 4:33 AM, Rich Hickey richhic...@gmail.com wrote: On Apr 29, 2010, at 4:21 AM, ataggart wrote: Functions named contains-key? and contains-val? would make a lot more sense to me than the current contains? and new seq-contains?. Anyone looking at contains-val? should expect it to be O(n). The only effective difference would be that the test value for contains-val? is consistently a single value rather than a [key value] tuple for maps. People don't consider sets, vectors, arrays or strings to have 'keys'. But, like maps, they all support fast lookup of some sort. Actually I do consider sets to have keys, since internally they are implemented using maps, so the exact same semantics apply for their lookup. They're just maps where the key and value are the same thing: protected APersistentSet(IPersistentMap impl){ this.impl = impl; } public boolean contains(Object key){ return impl.containsKey(key); } public Object get(Object key){ return impl.valAt(key); } Because of this I would also expect contains-val? to be constant-time for sets, so I think seq-contains? is a better name. Anyway, I'm a little weary of this discussion by now, (and I can't be the only one) so I'd be perfectly happy leaving things as they are. I am glad that a lot of thought goes into these names though; it definitely shows. -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.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: something stupid I'm trying to do
I'd use the built-in, partition user= (partition 2 (range 1 9)) ((1 2) (3 4) (5 6) (7 8)) And add a mapping operation user= (map vec (partition 2 (range 1 9))) ([1 2] [3 4] [5 6] [7 8]) Am I missing a requirement? On Apr 30, 11:55 am, Mark J. Reed markjr...@gmail.com wrote: I think you want this: (defn pairup [a b rest] (cons [a b] (if rest (apply pairup rest) []))) On Thu, Apr 29, 2010 at 3:32 PM, john.holland jbholl...@gmail.com wrote: I'm pounding my head against the wall trying to understand how to do a simple task. What I want to do is write a function that will take a even-numbered set of numbers and split them into pairs. What I have right now is the following user (defn pairup ([a b] [a b])([a b rest] (cons (pairup a b) (apply pairup rest))) ([] [] )) #'user/pairup user (pairup 1 2 3 4 5 6 7 8) ([1 2] [3 4] [5 6] 7 8) user I can't get the last pair into a vector like the others. Can someone tell me what I am doing wrong? I know there is probably a way using the language to do this but I ended up trying to do it from scratch as a learning exercise. Thanks John -- 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 -- Mark J. Reed markjr...@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 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 athttp://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: what is wrong with (use `clojure.contrib.string) ?
On Thu, Apr 29, 2010 at 10:43 PM, David Nolen dnolen.li...@gmail.comwrote: My rule of thumb is: use + :only require + :as I believe this should be documented as the 'suggested usage'. As contrary to Python where 'from module import *'(which is 'use' in clojure) is right in there saying 'you know what you are doing', clojure's use is inviting for newbie(import for java, use for clojure module) but it really should only be used sparsely or qualified with [:only] Another thing that is a bit confusing is the form different between (ns [:use ...]) vs naked (use ...). Sometimes, not putting into a vector works, sometimes it doesn't. -- 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: something stupid I'm trying to do
Sorry, let me try answering your questions instead of just proposing an alternative. :) As written, your base case and your recursive call are inconsistent. If you want (pairup 1 2 3 4) to return ([1 2] [3 4]), then you need to wind up calling (cons [1 2] [[3 4]]). What you're calling instead is (cons [1 2] [3 4]), because (pairup 3 4) returns a lone pair instead of a list containing a single pair. Basically, you can't call (cons (pairup) (pairup)) because the two arguments to (cons) are different: the first is an item, and the second is a list to cons the item onto. So the fix is to make the base case return ([a b]) instead of just [a b], and not to use recursion in the first argument to cons in your recurse case: (defn pairup ([a b] (list [a b])) ([a b rest] (cons [a b] (apply pairup rest I got an error when I tried ([a b]) instead of (list [a b]), by the way: Clojure 1.1.0 user= (cons [1 2] ([3 4])) java.lang.IllegalArgumentException: Wrong number of args passed to: PersistentVector (NO_SOURCE_FILE:0) On Thu, Apr 29, 2010 at 3:32 PM, john.holland jbholl...@gmail.com wrote: I'm pounding my head against the wall trying to understand how to do a simple task. What I want to do is write a function that will take a even-numbered set of numbers and split them into pairs. What I have right now is the following user (defn pairup ([a b] [a b])([a b rest] (cons (pairup a b) (apply pairup rest))) ([] [] )) #'user/pairup user (pairup 1 2 3 4 5 6 7 8) ([1 2] [3 4] [5 6] 7 8) user I can't get the last pair into a vector like the others. Can someone tell me what I am doing wrong? I know there is probably a way using the language to do this but I ended up trying to do it from scratch as a learning exercise. Thanks John -- 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 -- Mark J. Reed markjr...@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 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: something stupid I'm trying to do
On Fri, Apr 30, 2010 at 12:25 PM, Mark J. Reed markjr...@gmail.com wrote: I got an error when I tried ([a b]) instead of (list [a b]), by the way: Clojure 1.1.0 user= (cons [1 2] ([3 4])) java.lang.IllegalArgumentException: Wrong number of args passed to: PersistentVector (NO_SOURCE_FILE:0) To be clear, that's because vectors are functions on their indices; I meant to explain why I had to use the (list) form. -- Mark J. Reed markjr...@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 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 1.2 seq fn enhancement FAQ
On Fri, Apr 30, 2010 at 5:18 AM, Laurent PETIT laurent.pe...@gmail.com wrote: While it sounds soo evident now that you say that explicitly ( the contains? / get pair ), it may be good to reflect that in the docs of the functions rather than just keep this knowledge here ? Agreed. This explanation of the relationship between contains? and get should be reflected in the docs. I *finally* understand why contains? returns false for lists, rather than an error. -- 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: Problem with classpath (noob question)
On Thu, Apr 29, 2010 at 6:58 PM, Rainer wolf.rai...@gmail.com wrote: Hello, I'm stuck with Programming Clojure on page 37 on a Windows 7 machine. After downloading the examples dir into C:/clojure, I typed: user (require 'examples.introduction) and I got ; Evaluation aborted. java.io.FileNotFoundException: Could not locate examples/ introduction__init.class or examples/introduction.clj on classpath: (NO_SOURCE_FILE:0) My .emacs file looks like this: (setq swank-clojure-extra-classpaths (list C:/Clojure)) I'm not sure what version of Clojure Box you have, but in 1.1 you should set swank-clojure-classpath, not swank-clojure-extra-classpaths. 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.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure 1.2 seq fn enhancement FAQ
On Apr 30, 4:33 am, Rich Hickey richhic...@gmail.com wrote: People don't consider sets, vectors, arrays or strings to have 'keys'. But, like maps, they all support fast lookup of some sort. But of course we do. I point to the doc for contains? and get: Usage: (contains? coll key) Returns true if key is present in the given collection, otherwise returns false. Usage: (get map key) (get map key not-found) Returns the value mapped to key, not-found or nil if key not present. Both reference the notion of a key. If referencing keys in the documentation doesn't hurt, and makes its usage more clear, I can't see why that reasoning wouldn't follow to the function name itself, especially if we allow for a contains-val? (which I know is also Would contains-val? be fast for sets? As with any abstract method/function the worst-case is what's documented. Anyone looking at contains-val? should expect worst-case O(n), just as anyone looking at contains-key? should expect (near) O(1). The deeper question is: if an abstract method/function is documented to be worst-case O(n), then must all implementations be written to ensure the worst-case performance, even when it could be implemented in O(1) time? As a user of sets, I consider them collections of values, and I absolutely would reach for contains- val? in any library that had it, for use with sets. If so, and I used contains-val?, and I moved code from using sets to maps (happens frequently), or vectors (also happens) my perf would suddenly stink. If not fast on sets, why not? The reason isn't supported by the name. Your perf stinking is a product of you testing for values, and not keys. The alternative would have been to use contains? with your sets and watch (contains? s foo) blow up when you tried to use the same code against a vector. The mismatch with the seq values of maps is also disconcerting for something that would purport to be sequential, as the things returned by (seq amap) are key+value pairs. Only seq-contains? purports to be related to seq, whereas contains- val? purports to check if the value is in the collection, and to do so in worst-case O(n) time. Going back to your earlier point about swapping out datastructures, (contains-val? v foo) written against vectors would work just fine when handed a map; seq-contains? would give false negatives. Renaming contains? is not on the table. Very well. -- 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 1.2 seq fn enhancement FAQ
On 2010 Apr 30, at 7:33 AM, Rich Hickey wrote: People don't consider sets, vectors, arrays or strings to have 'keys'. That is not consistent with the documentation: Sets: http://clojure.org/data_structures: Sets support 'removal' with disj, as well as contains? and get, the latter returning the object that is held in the set which compares equal to the key, if found ... http://richhickey.github.com/clojure/clojure.core-api.html: hash-set ... (hash-set keys) ... Returns a new hash set with supplied keys. and similarly for sorted-set, sorted-set-by. It rings hollow to say People don't consider sets, vectors... to have 'keys' when your own documentation says that keys are what are used to build sets, or update vectors... and talks about those types using that term. I agree that contains?'s behavior on vectors is confusing for newcomers. That's not a reason for it to be different. And that people need a way to do that rummaging job. They of course can, with 'some'. But I also agree that 'some', being a higher-order function, would not necessarily be the tool newcomers would consider for the job of rummaging for a value. Perhaps it's a good first lesson, as they are not going to find filter-val etc either. But they will find zero? and wonder, WTF? There be a special function for #(= 0 %) and not for searching through sequences? (some #(= val %) ...) A) I remove seq-contains? B) I rename seq-contains? Perhaps: rummage function Usage: (rummage coll val) (rummage coll val not-found) Scans coll looking for val. Returns val if found, else not-found (or nil). I'm inclined towards A so we can all stop wasting time and energy on this unnecessary function. An unnecessary function that you just a few paragraphs prior acknowledged that people need? Yes, let's do stop wasting time and energy. Stuart says that this is FAQ #5, so let's just let it remain that. And leave the docs as they are, so you can come back again and thinking about keys and lookup and misleading expensive operations in the wrong way because we only had your docs to read. But what do I know, I'm just an amateur at wasting time on clojure, I only have a few measly hours a week. :) -Doug -- 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
defrecord question
Should this compile? (defprotocol P (p [this])) (defrecord R [k] P (p [{:keys [k]}] k)) java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.Symbol -- 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: defrecord question
I think you have your destructuring backwards. You fn should probably be (fn [{k :keys}] k) For example, user= ((fn [{k :keys}] k) {:keys Awesome}) Awesome On Apr 30, 2:46 pm, russellc russell.christop...@gmail.com wrote: Should this compile? (defprotocol P (p [this])) (defrecord R [k] P (p [{:keys [k]}] k)) java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.Symbol -- 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 athttp://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: defrecord question
Why does this work? (defrecord R [k]) (extend-protocol P R (p [{:keys [k]}] k)) On Fri, Apr 30, 2010 at 2:52 PM, Sean Devlin francoisdev...@gmail.comwrote: I think you have your destructuring backwards. You fn should probably be (fn [{k :keys}] k) For example, user= ((fn [{k :keys}] k) {:keys Awesome}) Awesome On Apr 30, 2:46 pm, russellc russell.christop...@gmail.com wrote: Should this compile? (defprotocol P (p [this])) (defrecord R [k] P (p [{:keys [k]}] k)) java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.Symbol -- 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 athttp:// 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 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: defrecord question
Oh, wait, my bad... you're getting the keyword args special destructuring. i.e., you're telling Clojure to expect a map and store the appropriate keys in the proper symbols user= ((fn [{:keys [k]}] (str k)) {:k Awesome :l Beer}) Awesome user= ((fn [{:keys [k l]}] (str k l)) {:k Awesome :l Beer}) AwesomeBeer Not 100% why you're having an issue, gotta think. On Apr 30, 2:56 pm, Russell Christopher russell.christop...@gmail.com wrote: Why does this work? (defrecord R [k]) (extend-protocol P R (p [{:keys [k]}] k)) On Fri, Apr 30, 2010 at 2:52 PM, Sean Devlin francoisdev...@gmail.comwrote: I think you have your destructuring backwards. You fn should probably be (fn [{k :keys}] k) For example, user= ((fn [{k :keys}] k) {:keys Awesome}) Awesome On Apr 30, 2:46 pm, russellc russell.christop...@gmail.com wrote: Should this compile? (defprotocol P (p [this])) (defrecord R [k] P (p [{:keys [k]}] k)) java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.Symbol -- 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 athttp:// 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 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 athttp://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 1.2 seq fn enhancement FAQ
On Apr 30, 2010, at 6:33 AM, Rich Hickey wrote: Would contains-val? be fast for sets? As a user of sets, I consider them collections of values, and I absolutely would reach for contains-val? in any library that had it, for use with sets. If so, and I used contains-val?, and I moved code from using sets to maps (happens frequently), or vectors (also happens) my perf would suddenly stink. If not fast on sets, why not? The reason isn't supported by the name. You should understand the performance characteristics of the data structures you employ, under whatever operations you subject them to. Being surprised when your code that looks stuff up by value slows down when you switch from sets to something else doesn't strike me as reasonable. 'contains?' and 'get' abstract over fast lookup. They are polymorphic on the collection type and on the nature of the looked-up thing. For maps the looked-up thing is a key, for sets: a value, for vectors, strings and arrays: an index. Calling it contains-key? doesn't make them the same, nor add any value. The objects in a set are both keys and values, and an index *is* a key. The documentation for get and contains? implies this, as others have noted. Renaming contains? is not on the table. I hope you will reconsider this, if not now then at some point in the future. For people that understand its relationship with get, it makes perfect sense (and I don't think I'm the only one :). As would contains-key?, I think. And there is a lot of client code. No need to rename immediately; alias and deprecate. And no one has come up with a better name that doesn't include caveats. I don't see any caveats for contains-key? other than the one addressed above. I do understand that this use of the word differs from that used in e.g., Java. But I'll make the same argument to Java devs that I do to the Lispers, who have seen many more of their prized words repurposed in Clojure (assoc, loop, do et al): The words can't mean the same thing forever without trapping us in the same semantics forever, and there are only so many good words. Everyone has to realize that this level of polymorphism in Clojure is unusual. I haven't seen a library with equivalents to get and contains?. Heck, in Java, Maps aren't even collections! So, should we adopt their nomenclature because it is familiar? contains? isn't a bad name because it's used differently in Java. It's bad because it's ambiguous, and because there's a much clearer name available. I agree that contains?'s behavior on vectors is confusing for newcomers. That's not a reason for it to be different. I disagree. The only options for right now are: A) I remove seq-contains? B) I rename seq-contains? Something involving the word 'scan', perhaps? -- 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
labrepl updated
I have updated the labrepl [1] to use the latest clojure 1.2 and contrib 1.2 snapshots. Also, most of the dependencies are now frozen to specific snapshot timestamps (the project.clj file may be of interest to people living on the development edge). After a lein clean; lein deps everything should work, please let me know if you see otherwise. Have a good weekend! Stu [1] http://github.com/relevance/labrepl -- 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 1.2 seq fn enhancement FAQ
On Apr 29, 3:21 am, ataggart alex.tagg...@gmail.com wrote: Functions named contains-key? and contains-val? would make a lot more sense to me than the current contains? and new seq-contains?. Amen. Even independent of any performance expectations. -- 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: something stupid I'm trying to do
On 30 April 2010 18:25, Mark J. Reed markjr...@gmail.com wrote: [...] (defn pairup ([a b] (list [a b])) ([a b rest] (cons [a b] (apply pairup rest I got an error when I tried ([a b]) instead of (list [a b]), by the way: Clojure 1.1.0 user= (cons [1 2] ([3 4])) java.lang.IllegalArgumentException: Wrong number of args passed to: PersistentVector (NO_SOURCE_FILE:0) Well, you didn't *have* to call list. You could have quoted the literal list: (defn pairup ([a b] '([a b])) ([a b rest] (cons [a b] (apply pairup rest -- 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 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: something stupid I'm trying to do
Of course. Which is what I would have done automatically with a Lispier construct. Just still not used to seeing literal vectors as functions. :) On Friday, April 30, 2010, Michael Wood esiot...@gmail.com wrote: On 30 April 2010 18:25, Mark J. Reed markjr...@gmail.com wrote: [...] (defn pairup ([a b] (list [a b])) ([a b rest] (cons [a b] (apply pairup rest I got an error when I tried ([a b]) instead of (list [a b]), by the way: Clojure 1.1.0 user= (cons [1 2] ([3 4])) java.lang.IllegalArgumentException: Wrong number of args passed to: PersistentVector (NO_SOURCE_FILE:0) Well, you didn't *have* to call list. You could have quoted the literal list: (defn pairup ([a b] '([a b])) ([a b rest] (cons [a b] (apply pairup rest -- 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 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 -- Mark J. Reed markjr...@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 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: something stupid I'm trying to do
On 2010 Apr 30, at 5:45 PM, Mark J. Reed wrote: Of course. Which is what I would have done automatically with a Lispier construct. Just still not used to seeing literal vectors as functions. :) On Friday, April 30, 2010, Michael Wood esiot...@gmail.com wrote: Well, you didn't *have* to call list. You could have quoted the literal list: (defn pairup ([a b] '([a b])) ([a b rest] (cons [a b] (apply pairup rest Hmmm, that quotes the entire form: user= '([a b]) ([a b]) -Doug -- 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 1.2 seq fn enhancement FAQ
Phil Hagelberg p...@hagelb.org writes: Actually I do consider sets to have keys, since internally they are implemented using maps, so the exact same semantics apply for their lookup. They're just maps where the key and value are the same thing: But that implementation is one of convenience, of possibly admirable laziness, and it's none of our business. A key is something apart from a value it refers, but in sets, there's no separate value being referred to. The value is the only thing in play. Where we get hung up in software is with the flexibility to define equality or sufficient sameness in set implementations by taking only part of the stored values into account. The same idea doesn't exist in the mathematical view of sets. Our software would be much clearer if sets didn't tolerate these key comparison views, and would instead force one to use a map in cases where such a key comparison view (being something less than the value itself) is necessary. -- Steven E. Harris -- 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: something stupid I'm trying to do
On 30 April 2010 23:49, Douglas Philips d...@mac.com wrote: On 2010 Apr 30, at 5:45 PM, Mark J. Reed wrote: Of course. Which is what I would have done automatically with a Lispier construct. Just still not used to seeing literal vectors as functions. :) On Friday, April 30, 2010, Michael Wood esiot...@gmail.com wrote: Well, you didn't *have* to call list. You could have quoted the literal list: (defn pairup ([a b] '([a b])) ([a b rest] (cons [a b] (apply pairup rest Hmmm, that quotes the entire form: user= '([a b]) ([a b]) Ouch. Of course. Must be past my bed time :) -- 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 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 1.2 seq fn enhancement FAQ
Clojure embraces this laziness: user= (get #{:foo :bar} :foo) :foo 'get uses a key to return a value. A vector is not a map is not a set, but all of them can have their values accessed in constant-time using a key. On Apr 30, 3:14 pm, Steven E. Harris s...@panix.com wrote: Phil Hagelberg p...@hagelb.org writes: Actually I do consider sets to have keys, since internally they are implemented using maps, so the exact same semantics apply for their lookup. They're just maps where the key and value are the same thing: But that implementation is one of convenience, of possibly admirable laziness, and it's none of our business. A key is something apart from a value it refers, but in sets, there's no separate value being referred to. The value is the only thing in play. Where we get hung up in software is with the flexibility to define equality or sufficient sameness in set implementations by taking only part of the stored values into account. The same idea doesn't exist in the mathematical view of sets. Our software would be much clearer if sets didn't tolerate these key comparison views, and would instead force one to use a map in cases where such a key comparison view (being something less than the value itself) is necessary. -- Steven E. Harris -- 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 athttp://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: something stupid I'm trying to do
Ok, so I was right the first time. It think it's past everyone's bedtime. :) On Fri, Apr 30, 2010 at 5:49 PM, Douglas Philips d...@mac.com wrote: On 2010 Apr 30, at 5:45 PM, Mark J. Reed wrote: Of course. Which is what I would have done automatically with a Lispier construct. Just still not used to seeing literal vectors as functions. :) On Friday, April 30, 2010, Michael Wood esiot...@gmail.com wrote: Well, you didn't *have* to call list. You could have quoted the literal list: (defn pairup ([a b] '([a b])) ([a b rest] (cons [a b] (apply pairup rest Hmmm, that quotes the entire form: user= '([a b]) ([a b]) -Doug -- 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 -- Mark J. Reed markjr...@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 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: something stupid I'm trying to do
On 30 April 2010 18:25, Mark J. Reed markjr...@gmail.com wrote: (defn pairup ([a b] (list [a b])) ([a b rest] (cons [a b] (apply pairup rest That will overflow the stack when you do, say, (last (apply pairup (range 2))) That can be fixed by wrapping (cons ...) in lazy-seq. Another version: (defn pairup [ args] (map vector args (rest args))) Sincerely, Michał -- 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: something stupid I'm trying to do
0On Fri, Apr 30, 2010 at 8:41 PM, Michał Marczyk michal.marc...@gmail.comwrote: That will overflow the stack when you do, say, (last (apply pairup (range 2))) That can be fixed by wrapping (cons ...) in lazy-seq. Sure. Laziness good. Another version: (defn pairup [ args] (map vector args (rest args))) Nope, that doubles the middle elements: user= (pairup 1 2 3 4) ([1 2] [2 3] [3 4]) -- Mark J. Reed markjr...@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 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
rand-int with bignums
In an earlier thread, in which I learned (from Timothy Pratley) that (. (new java.util.Random) X) gives an error if X is a bignum, I said that at least Clojure's rand-int does the right thing. Upon further investigation I see that this is only true in the sense that it doesn't produce an error. In fact it does something that seems pretty odd to me, at least in Clojure 1.1.0 / Java 1.6.0_17, which is all I've tried. It does seem to return a random integer between 0 and 2^31-1 but it rather frequently returns exactly 2^31-1 (which is 2147483647): user= (rand-int 100) 2035176337 user= (rand-int 100) 2147483647 user= (rand-int 100) 2147483647 user= (rand-int 100) 2147483647 user= (rand-int 100) 1859741466 user= (rand-int 100) 2147483647 user= Looking at the source I see that it calls int which overflows with bignums (whether by design or not I don't know): user= (int 2147483648) -2147483648 I don't immediately see why this would would cause rand-int to produce 2147483647 so many times... maybe it's somehow an interaction with the resolution of the float from the call to rand? In any event I guess this is somehow the source of the behavior. Anyway, for my present application this doesn't matter much -- I'm just punting and using 2147483647 as the limit if I'm given a bignum -- but: - Mightn't rand-int be written to really do the right thing and return a random integer between 0 (inclusive) and n (exclusive), even if n is a bignum? - If there's a reason that rand-int shouldn't do this then is there another straightforward way get the same effect, maybe with some java library that I don't know about? Thanks, -Lee -- Lee Spector, Professor of Computer Science School of Cognitive Science, Hampshire College 893 West Street, Amherst, MA 01002-3359 lspec...@hampshire.edu, http://hampshire.edu/lspector/ Phone: 413-559-5352, Fax: 413-559-5438 Check out Genetic Programming and Evolvable Machines: http://www.springer.com/10710 - http://gpemjournal.blogspot.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 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
Problem reading record instances
I am unable to read-string record instances produced by pr-str. user (defrecord Z [x y]) user.Z user (read-string (pr-str (Z. 1 2))) ; Evaluation aborted. The exception is: java.lang.Exception: No dispatch macro for: : [Thrown class java.lang.RuntimeException] However, struct instances are read correctly. Am I correct in assuming that pr-str/read-str work for all clojure instances? (All of this with the latest clojure 1.2.0-SNAPSHOT) Thanks, -- 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