Problems embedding Himera (multiple clojurescript compiler libs in same project?)
I'm trying to use Himera as a library, to compile clojurescript forms I'm getting from somewhere. In my project, I also have clojurescript files that I want to compile with other means, using cljsbuild and/or noir-cljs. The issue is, having Himera on the classpath is making this impossible. The typical failure is the java.lang.AssertionError: Assert failed: Can't recur here exception. Or, even stranger errors. For instance, if I fire up the repl, and invoke cljsc/build directly, sometimes I get Parse error. XML runtime not available I've set my exclusions so that there's only a single copy of the clojurescript jar. (I've tried versions down to 971 to no avail) I can just extract/replicate the desired bits of code into my own project (and I will if there is no solution forthcoming), but I would like to understand why this is happening. -- 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: Should I better use a state monad (and how)?
On Apr 15, 8:25 pm, Nicolas Buduroi nbudu...@gmail.com wrote: I'm working on a turn-based game and I'm looking for a good way to manage states. In the game each turn is composed of multiple phases. I started by using atoms for the phases field (this is a sequence of functions) in a record and realized that it wouldn't be ideal to keep track of states in the case where I'd need to keep a snapshot of every phases. Here's the original code I had: (defrecord Game [phases] (next-phase [this] (stop-timer) (swap! phases #(conj (vec (rest %)) (first %))) (log :info change phase to %s (key (first @phases))) (start-phase this)) I then started to think that this would be a good opportunity to use a state monad. I've tried to reimplement the above code using the algo.monads library but the result was less than satisfactory (probably due to my own shortcoming), here's the monadic version: (defrecord Game [phases] (next-phase [this] (- ((domonad state-m [_ (fn [s] (stop-timer) [s s]) _ (update-state (fn [s] (update-in s [:phases] #(conj (vec (rest %)) (first %) _ (fn [s] (log :info change phase to %s (key (first (:phases s [s s])] nil) state) second start-phase)) As my code probably doesn't need the full power of the state monad, I tried to write a lighter-weight version using the following macro: (defmacro [ state-and-forms] (reduce #(list (if ('#{fn fn*} (first %2)) %2 `(fn [s#] ~%2 s#)) %) state-and-forms)) Which let me write: (next-phase [state] ( state (stop-timer) (fn [s] (update-in s [:phases] #(conj (vec (rest %)) (first % #(do (log :info change phase to %s (key (first (:phases % %) #(start-phase %))) With some more helper macro this version looks promising. In the end I wonder if there's some Clojure feature I'm overlooking or if I should rethink the whole solution? Is there a better way to accomplish this? #(conj (vec (rest %)) (first %)) is a really awful way to implement a queue. Just use clojure.lang.PersistentQueue, which works with the conj/peek/pop functions in clojure.core. -- 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: How Do I Install New Version Of Clojure?
On Apr 15, 1:45 am, Anto anto.aravinth@gmail.com wrote: I want to install clojure version 1.3, which I guess is the latest. I tried sudo apt-get install clojure which installs clojure 1.1 by default. I use Ubuntu 10.10 Thanks in advance. Hi, Anto. I've got some beginner instructions written up at http://www.unexpected-vortices.com/clojure/brief-beginners-guide/ that I hope folks find useful. They cover installation (or, rather, the notion that you let lein handle it for you). ---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
Saving Java objects/Clojure forms to text file
I want to save a list of Clojure maps to a text file. The problem is I have a :date key which contains a java.util.Date object, At the moment I am using: (spit file.txt clj-map) to save the file. However the dates are printed in the format #Date Mon Apr 16 15:22:27 BST 2012 How can I store the date in a text file and read it back without falling back on Java serialization? Thanks, Adam -- 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: Saving Java objects/Clojure forms to text file
How can I store the date in a text file and read it back without falling back on Java serialization? Upgrade to Clojure 1.4, which includes extensible support for parsing and serializing custom data types, with dates being one of the built-in types. It will all work automatically. -- Dave -- 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: New(er) Clojure cheatsheet hot off the presses
I just checked the http://clojure.org/cheatsheet seing there just the old version without any tooltips. Would anyone put there a new one with tooltips? Thx Bost -- 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: Saving Java objects/Clojure forms to text file
I would serialize to json and save the dates in millis. That's been working for me for quite awhile. Cheers, Jay On Mon, Apr 16, 2012 at 10:29 AM, Adam Markham adamjmark...@gmail.com wrote: I want to save a list of Clojure maps to a text file. The problem is I have a :date key which contains a java.util.Date object, At the moment I am using: (spit file.txt clj-map) to save the file. However the dates are printed in the format #Date Mon Apr 16 15:22:27 BST 2012 How can I store the date in a text file and read it back without falling back on Java serialization? Thanks, Adam -- 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: Extracting string literals from codebase
Thanks for the suggestion. This ended up being just what I was looking for. I wrote a version that used this, then went to try the analyze library recently announced (in hopes of getting line numbers). The analyze library depends on a beta release of Clojure 1.4, and I decided just to stick with simpler solution. I should add that analyze looks to have lots of potential uses. I'm eager to use it in the future. Thanks again, -M On Wednesday, April 11, 2012 1:44:47 PM UTC-5, Armando Blancas wrote: Maybe walking the result of (read-string (str ( (slurp somefile.clj) ))) -- 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: Accessing defrecord from another namespace
Does app.two.b have a hyphen? If so, make it an underscore when importing. I've been bitten by that issue before. Also, +1 to correct names suggested by Vinzent. -M On Thursday, April 12, 2012 1:03:49 PM UTC-5, Adam Markham wrote: I have two namespaces as follows: (ns app.one.a (:require [ns.app.two.b]) (:import [ns.app.two.b Book])) (def b (Book. A Book Adam)) (ns app.two.b) (defrecord Book [title author]) However whenever I try to import the defrecord I get a ClassNotFoundException thrown. I tried AOT compiling the namespace containing the defrecord with (:gen-class) but it made no difference. Is there anything that i'm doing wrong? Thanks, Adam -- 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: Saving Java objects/Clojure forms to text file
Thanks. Ended up going the Clojure 1.4 instant literal way as I just wanted to read and write the dates not use them for anything else. Thanks, Adam On Apr 16, 3:37 pm, David Powell djpow...@djpowell.net wrote: How can I store the date in a text file and read it back without falling back on Java serialization? Upgrade to Clojure 1.4, which includes extensible support for parsing and serializing custom data types, with dates being one of the built-in types. It will all work automatically. -- Dave -- 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 do you use defmulti to create a function with a variable number of args?
How do you use defmulti to create a function with a variable number of args? For example, add-item is wrapping a Java method that can take a variable number of args, and so here I am trying to make add-item take zero, one, or two args. Notice there are two singe-arg funcs -- each taking a different type... (defmulti add-item class) (defmethod add-item [] (add-item nil nil)) (defmethod add-item Integer [id] (add-item id nil)) (defmethod add-item Map [props] (add-item nil props)) (defmethod add-item :default [id props] ( ; call some Java method ) Unless I am overlooking something, I don't see anything on the Multimethods page (http://clojure.org/multimethods) about defmulti or defmethod taking a variable number of arguments -- they all take the same number of arguments of different types. - James -- 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
A pr-str alternative that quotes lists?
Frequently when working in the repl I want to take a datastructure and copy it into a test, however if that datastructure contains lists or more often lazy-seqences these are printed within unquoted (), so when I copy the result into my test I need to replace these lists with vectors or quote them. (pr-str {:a (range 0 3)}) = {:a (0 1 2)} If I read the result as clojure code I would read it as call the function 0 with the arguments 1 2 and save the result as the value to :a in the map, which is not a correct interpretation of the original datastructure unless that datastructure is actually code, but most of the time it is not. Most of the time its a datastructure that is printed at the repl during development... I think it would be very useful to have a binding or alternative method that should be used to print results at the repl which would print datastructures in a form that correctly represents the code necessary to create them, either {:a [0 1 2]} or {:a '(0 1 2)}. Personally, I think vectors would be a more idiomatic representation of serialized list structure, but quoted list would at least be a correct representation of the datastructure that one could easily copy and paste into a test. -- 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 pr-str alternative that quotes lists?
As an alternative, you could quote the entire expression (you can quote anything, not just lists) when copying data structures into a test. -S -- 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: How do you use defmulti to create a function with a variable number of args?
This should do the trick: (defmulti add-item (fn [i other] (class i)) Thanks, Ambrose On Mon, Apr 16, 2012 at 5:33 AM, James Thornton james.thorn...@gmail.comwrote: How do you use defmulti to create a function with a variable number of args? For example, add-item is wrapping a Java method that can take a variable number of args, and so here I am trying to make add-item take zero, one, or two args. Notice there are two singe-arg funcs -- each taking a different type... (defmulti add-item class) (defmethod add-item [] (add-item nil nil)) (defmethod add-item Integer [id] (add-item id nil)) (defmethod add-item Map [props] (add-item nil props)) (defmethod add-item :default [id props] ( ; call some Java method ) Unless I am overlooking something, I don't see anything on the Multimethods page (http://clojure.org/multimethods) about defmulti or defmethod taking a variable number of arguments -- they all take the same number of arguments of different types. - James -- 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: How do you use defmulti to create a function with a variable number of args?
note, I didn't test any of these, but they should work (possibly with a tweak or 2) There's quite a few ways to do this, here's one. (defmulti add-item (fn [ args] (condp count args 0 :none 1 (class (first args)) :default)) (defmethod add-item :none (add-item nil nil)) (defmethod add-item Integer [id] (add-item id nil)) (defmethod add-item Map [props] (add-item nil props)) (defmethod add-item :default [id props] ( ; call some Java method ) Here's another (defmulti add-item (fn [ args] (map class args) (defmethod add-item [] (add-item nil nil)) (defmethod add-item [Integer] [id] (add-item id nil)) (defmethod add-item [Map] [props] (add-item nil props)) (defmethod add-item :default [id props] ( ; call some Java method ) Cheers, Jay On Sun, Apr 15, 2012 at 5:33 PM, James Thornton james.thorn...@gmail.com wrote: How do you use defmulti to create a function with a variable number of args? For example, add-item is wrapping a Java method that can take a variable number of args, and so here I am trying to make add-item take zero, one, or two args. Notice there are two singe-arg funcs -- each taking a different type... (defmulti add-item class) (defmethod add-item [] (add-item nil nil)) (defmethod add-item Integer [id] (add-item id nil)) (defmethod add-item Map [props] (add-item nil props)) (defmethod add-item :default [id props] ( ; call some Java method ) Unless I am overlooking something, I don't see anything on the Multimethods page (http://clojure.org/multimethods) about defmulti or defmethod taking a variable number of arguments -- they all take the same number of arguments of different types. - James -- 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: How do you use defmulti to create a function with a variable number of args?
I might be wrong, but I think that would cause (add-item 1 {:prop here}) to call the wrong defmethod (should call 4th, calls 2nd) On Mon, Apr 16, 2012 at 12:47 PM, Ambrose Bonnaire-Sergeant abonnaireserge...@gmail.com wrote: This should do the trick: (defmulti add-item (fn [i other] (class i)) Thanks, Ambrose On Mon, Apr 16, 2012 at 5:33 AM, James Thornton james.thorn...@gmail.com wrote: How do you use defmulti to create a function with a variable number of args? For example, add-item is wrapping a Java method that can take a variable number of args, and so here I am trying to make add-item take zero, one, or two args. Notice there are two singe-arg funcs -- each taking a different type... (defmulti add-item class) (defmethod add-item [] (add-item nil nil)) (defmethod add-item Integer [id] (add-item id nil)) (defmethod add-item Map [props] (add-item nil props)) (defmethod add-item :default [id props] ( ; call some Java method ) Unless I am overlooking something, I don't see anything on the Multimethods page (http://clojure.org/multimethods) about defmulti or defmethod taking a variable number of arguments -- they all take the same number of arguments of different types. - James -- 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 -- 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
question about partial
I trying to grok partial and - so I have the following example. (defn f[x y] (+ x y)) ((partial f 2) 3) works as expected , returning 5 but if I try to use - (- 3 (partial f 2)) I get #core$partial$fn__3796 clojure.core$partial$fn__3796@4c629f43 But if I first define (def fp (partial f 2)) then (- 3 fp) returns 5 as expected What's going on ? -- 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: question about partial
reading material: http://blog.fogus.me/2009/09/04/understanding-the-clojure-macro/ When you say (- 3 (partial f 2)) that evaluates to (partial 3 f 2) - which is obviously not what you want. Likewise, (- 3 fp) expands to (fp 3), which works fine, as you noticed. The important thing to remember is that the threading operator is a macro. On Mon, Apr 16, 2012 at 12:53 PM, larry larrye2...@gmail.com wrote: I trying to grok partial and - so I have the following example. (defn f[x y] (+ x y)) ((partial f 2) 3) works as expected , returning 5 but if I try to use - (- 3 (partial f 2)) I get #core$partial$fn__3796 clojure.core$partial$fn__3796@4c629f43 But if I first define (def fp (partial f 2)) then (- 3 fp) returns 5 as expected What's going on ? -- 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: question about partial
Sorry, I meant to link this post: http://blog.fogus.me/2010/09/28/thrush-in-clojure-redux/ On Mon, Apr 16, 2012 at 12:58 PM, Jay Fields j...@jayfields.com wrote: reading material: http://blog.fogus.me/2009/09/04/understanding-the-clojure-macro/ When you say (- 3 (partial f 2)) that evaluates to (partial 3 f 2) - which is obviously not what you want. Likewise, (- 3 fp) expands to (fp 3), which works fine, as you noticed. The important thing to remember is that the threading operator is a macro. On Mon, Apr 16, 2012 at 12:53 PM, larry larrye2...@gmail.com wrote: I trying to grok partial and - so I have the following example. (defn f[x y] (+ x y)) ((partial f 2) 3) works as expected , returning 5 but if I try to use - (- 3 (partial f 2)) I get #core$partial$fn__3796 clojure.core$partial$fn__3796@4c629f43 But if I first define (def fp (partial f 2)) then (- 3 fp) returns 5 as expected What's going on ? -- 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: A pr-str alternative that quotes lists?
On Apr 16, 10:45 am, Stuart Sierra the.stuart.sie...@gmail.com wrote: As an alternative, you could quote the entire expression (you can quote anything, not just lists) when copying data structures into a test. -S It never occurred to me to do that so I guess that works... As my alternative, I went off and wrote this as I find it easier to mentally parse datastructures that uses vectors rather than quotes. (defn lists-vectors Replaces lists and lazy sequences with vectors [obj] (let [f #(if (or (list? %) (instance? clojure.lang.LazySeq %)) (apply vector %) %)] (postwalk f obj))) -- 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: question about partial
(- 3 ((partial f 2))) should also work. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com 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 pr-str alternative that quotes lists?
If you go down that path, I think vec (http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/vec) is worth looking at. I've always understood that vec turns lists into vectors, but leaves vectors alone... which looks like what you are doing. On Mon, Apr 16, 2012 at 1:02 PM, kurtharriger kurtharri...@gmail.com wrote: On Apr 16, 10:45 am, Stuart Sierra the.stuart.sie...@gmail.com wrote: As an alternative, you could quote the entire expression (you can quote anything, not just lists) when copying data structures into a test. -S It never occurred to me to do that so I guess that works... As my alternative, I went off and wrote this as I find it easier to mentally parse datastructures that uses vectors rather than quotes. (defn lists-vectors Replaces lists and lazy sequences with vectors [obj] (let [f #(if (or (list? %) (instance? clojure.lang.LazySeq %)) (apply vector %) %)] (postwalk f obj))) -- 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: A pr-str alternative that quotes lists?
On Apr 16, 11:07 am, Jay Fields j...@jayfields.com wrote: If you go down that path, I think vec (http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/vec) is worth looking at. I've always understood that vec turns lists into vectors, but leaves vectors alone... which looks like what you are doing. good call, now I can use seq? instead to simplify the conditional (defn lists-vectors Replaces lists and lazy sequences with vectors [obj] (let [f #(if (seq? %) (vec %) %)] (postwalk f obj))) -- 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
PersistentHashMaps coming to ClojureScript
Thanks to Michal Marczyk we're closing in on PersistentHashMaps: http://jsperf.com/cljs-persistent-hash-map-tiny-assoc http://jsperf.com/cljs-persistent-hash-map-large-assoc http://jsperf.com/cljs-persistent-hash-map-access Performance is looking pretty good and, as usual, very stellar on V8. David -- 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: PersistentHashMaps coming to ClojureScript
Thanks Michal Marczyk! This is a really important addition. On Mon, Apr 16, 2012 at 2:15 PM, David Nolen dnolen.li...@gmail.com wrote: Thanks to Michal Marczyk we're closing in on PersistentHashMaps: http://jsperf.com/cljs-persistent-hash-map-tiny-assoc http://jsperf.com/cljs-persistent-hash-map-large-assoc http://jsperf.com/cljs-persistent-hash-map-access Performance is looking pretty good and, as usual, very stellar on V8. David -- 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
Inconsistent refs within an STM transaction.
Hi, [disclojure]: I've asked about this on SO, but figured out what was happening myself[1] and that led to this enquiry. It seems that the consistency of refs within an STM transaction (dosync) depends on whether the ref has history. So if you create 2 refs and then read them in a transaction they could be inconsistent with each other. i.e they won't necessarily return the value the ref had at the start of the transaction. However, if you give the refs some history by updating them in a prior transaction, then the two refs will be consistent with each other in subsequent transactions. This seems rather dangerous to me. Is there a rational for not creating at least 1 history entry for a ref at ref creation time. Neale {t: @sw1nn https://twitter.com/#!/sw1nn, w: sw1nn.com } [1] http://stackoverflow.com/questions/10178639/are-refs-really-consistent-within-a-stm-transaction -- 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: Light Table - a new IDE concept
Wow, that really blew me away. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com 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: ANN: A more fully-featured lein-vimclojure
On Tue Apr 17 00:21 2012, Rostislav Svoboda wrote: I just quickly tried out the lein-tarsier and I'm getting: $ lein vimclojure Starting VimClojure server on 127.0.0.1, port 2113 Happy hacking! (now I open http://127.0.0.1:2113 in my browser) java.lang.OutOfMemoryError: Java heap space at vimclojure.nailgun.NGSession.run(NGSession.java:199) java.io.EOFException at java.io.DataInputStream.readFully(DataInputStream.java:197) at java.io.DataInputStream.readFully(DataInputStream.java:169) at vimclojure.nailgun.NGSession.run(NGSession.java:195) Any idea what am I doing wrong? I use Leiningen 1.7.1 Well, the VimClojure server is not a web server, and doesn't speak HTTP. Instead, it uses the 'Nailgun' protocol. The general use case for it is in conjuction with the VimClojure Vim plug-in http://www.vim.org/scripts/script.php?script_id=2501. Using the two together allows Vim to offer some nice features for Clojure editing, such as completion (intellisense), docstring lookup, etc. I hope this helps. Sincerely, Daniel signature.asc Description: Digital signature
Re: Accessing defrecord from another namespace
On Mon, Apr 16, 2012 at 7:30 PM, Adam Markham adamjmark...@gmail.com wrote: I actually made an error when typing the code out in my message, so I had no 'ns' in front of the namespace name. The issue was as you said Mark I used hyphens but they needed to be underscores. I went into the project classes folder and found that the package had underscores in its name. Something so trivial caused so much trouble. This is causing a fair bit of lossage (including of pulled-out hair, it seems) and seems inelegant. It occurs to me that a hyphen is never seen in any Java class or package name. So it probably wouldn't break anything to make the import function convert all hyphens to underscores when processing each class or package name, and it would make this wart when importing defrecords go away. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com 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: Tornado-like async (web) server framework?
I am working on a tiny web server and http client in clojure and java. It's using java's async Socket IO. https://github.com/shenfeng/http-kit The code is mostly written in java, It will expose a nice clojure API. My goal are async, fast, RAM efficiency, clean and compact code. I write it for Rssminer(http://rssminer.net, https://github.com/shenfeng/rssminer). The documentation is not ready. The server's unit test code: https://github.com/shenfeng/http-kit/blob/master/test/me/shenfeng/http/server/server_test.clj The production code of Rssminer is now using: https://github.com/shenfeng/async-http-client https://github.com/shenfeng/async-ring-adapter The two are written on top of netty, a great java NIO framework. I plan to replace it with http-kit. On Apr 16, 9:51 am, Stefan Arentz ste...@arentz.ca wrote: There is a lovely little web server for Python called Tornado. Tornado is an async server that also includes an async http client that plugs right in the server's event loop. This makes it really simple to build scalable web services that call other web services, which is what I mostly use it for. I would love to do the same in Clojure but I have no idea where to start. Ideally I would use an async server or framework in the style of Tornado or Twisted. But since Java has excellent thread support I guess I could also use an http lib that allows me to run requests in parallel. Who has some hints or pointers? S. -- 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: Inconsistent refs within an STM transaction.
Hi, [disclojure]: I've asked about this on SO, but figured out what was happening myself[1] and that led to this enquiry. It seems that the consistency of refs within an STM transaction (dosync) depends on whether the ref has history. So if you create 2 refs and then read them in a transaction they could be inconsistent with each other. i.e they won't necessarily return the value the ref had at the start of the transaction. However, if you give the refs some history by updating them in a prior transaction, then the two refs will be consistent with each other in subsequent transactions. This seems rather dangerous to me. Is there a rational for not creating at least 1 history entry for a ref at ref creation time. Neale {t: @sw1nn, w: sw1nn.com } [1] http://stackoverflow.com/questions/10178639/are-refs-really-consistent-within-a-stm-transaction Hi Neale, Your example does not appear to match your conclusion. It shows that a transaction restarts, and that the reads are all consistent as of the restarted transaction. Cheers, Stu Stuart Halloway Clojure/core http://clojure.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: Inconsistent refs within an STM transaction.
So if you create 2 refs and then read them in a transaction they could be inconsistent with each other. i.e they won't necessarily return the value the ref had at the start of the transaction. However, if you give the refs some history by updating them in a prior transaction, then the two refs will be consistent with each other in subsequent transactions. This seems rather dangerous to me. Is there a rational for not creating at least 1 history entry for a ref at ref creation time. I haven't looken into your examples in detail, but clojure has http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/ensure to get consistent reads. I don't know exactly why read skew is allowed by default. Maybe it's along the lines of: If reads were consistent by default, performance would suffer and write skew would still be possible (which can be prevented by (ref-set ref @ref)) kind regards -- 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: Inconsistent refs within an STM transaction.
Hi Transaction read point is changed every time when transaction is started or retried.So the result is all right.If you want the ref1 cloud not be modified by other transactions ,you can use ensure: (defn deref-delay-deref [ref1 ref2 delay] (.start (Thread. #((println READ start) (dosync (println transaction starting) * (ensure ref1)* (let [a @ref2] (Thread/sleep delay) (println S r1= @ref1))) ; should be consistent with @ref2 (println READ end) 2012/4/17 Herwig Hochleitner hhochleit...@gmail.com So if you create 2 refs and then read them in a transaction they could be inconsistent with each other. i.e they won't necessarily return the value the ref had at the start of the transaction. However, if you give the refs some history by updating them in a prior transaction, then the two refs will be consistent with each other in subsequent transactions. This seems rather dangerous to me. Is there a rational for not creating at least 1 history entry for a ref at ref creation time. I haven't looken into your examples in detail, but clojure has http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/ensure to get consistent reads. I don't know exactly why read skew is allowed by default. Maybe it's along the lines of: If reads were consistent by default, performance would suffer and write skew would still be possible (which can be prevented by (ref-set ref @ref)) kind regards -- 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 -- 庄晓丹 Email:killme2...@gmail.com xzhu...@avos.com Site: http://fnil.net Twitter: @killme2008 -- 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: question about partial
On Monday, April 16, 2012 10:02:48 AM UTC-7, Cedric Greevey wrote: (- 3 ((partial f 2))) should also work. I just wrote that it DOESN'T WORK. That's the point of the question.I should get 5 instead I get t#core$partial$fn__3796 clojure.core$partial$fn__3796@4c629f43 -- 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: question about partial
Compare the number of brackets in Cedric's example to yours. Ambrose On Tue, Apr 17, 2012 at 1:18 PM, larry larrye2...@gmail.com wrote: On Monday, April 16, 2012 10:02:48 AM UTC-7, Cedric Greevey wrote: (- 3 ((partial f 2))) should also work. I just wrote that it DOESN'T WORK. That's the point of the question.I should get 5 instead I get t#core$partial$fn__3796 clojure.core$partial$fn__3796@4c629f43 -- 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: question about partial
user= (defn f[x y] (+ x y)) #'user/f user= (- 3 ((partial f 2))) 5 It must works :). Please notice the extra parentheses. 2012/4/17 larry larrye2...@gmail.com On Monday, April 16, 2012 10:02:48 AM UTC-7, Cedric Greevey wrote: (- 3 ((partial f 2))) should also work. I just wrote that it DOESN'T WORK. That's the point of the question.I should get 5 instead I get t#core$partial$fn__3796 clojure.core$partial$fn__3796@4c629f43 -- 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 -- 庄晓丹 Email:killme2...@gmail.com xzhu...@avos.com Site: http://fnil.net Twitter: @killme2008 -- 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: question about partial
On Mon, Apr 16, 2012 at 10:18 PM, larry larrye2...@gmail.com wrote: On Monday, April 16, 2012 10:02:48 AM UTC-7, Cedric Greevey wrote: (- 3 ((partial f 2))) should also work. I just wrote that it DOESN'T WORK. That's the point of the question.I should get 5 instead I get t#core$partial$fn__3796 clojure.core$partial$fn__3796@4c629f43 Hint: (- 3 ((partial f 2) #_argument goes here)) -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- 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: Inconsistent refs within an STM transaction.
Hi Stu, The point is that there's no reason for the READ transaction to restart, it has only made reads of refs and those reads should be consistent with each other from the snapshot of the the ref world as per... In practice, this means: 1. All reads of Refs will see a consistent snapshot of the 'Ref world' as of the starting point of the transaction (its 'read point'). The transaction *will*see any changes it has made. This is called the * in-transaction-value* * * from: http://clojure.org/refs The fact that the behaviour changes in the presence of history is a problem in my opinion. Yes you can 'ensure' that the refs aren't modified, but that means writes are blocked by reads - is that desired? Neale {t: @sw1nn https://twitter.com/#!/sw1nn, w: sw1nn.com } On Tue, Apr 17, 2012 at 2:59 AM, Stuart Halloway stuart.hallo...@gmail.comwrote: Hi, [disclojure]: I've asked about this on SO, but figured out what was happening myself[1] and that led to this enquiry. It seems that the consistency of refs within an STM transaction (dosync) depends on whether the ref has history. So if you create 2 refs and then read them in a transaction they could be inconsistent with each other. i.e they won't necessarily return the value the ref had at the start of the transaction. However, if you give the refs some history by updating them in a prior transaction, then the two refs will be consistent with each other in subsequent transactions. This seems rather dangerous to me. Is there a rational for not creating at least 1 history entry for a ref at ref creation time. Neale {t: @sw1nn https://twitter.com/#!/sw1nn, w: sw1nn.com } [1] http://stackoverflow.com/questions/10178639/are-refs-really-consistent-within-a-stm-transaction Hi Neale, Your example does not appear to match your conclusion. It shows that a transaction restarts, and that the reads are all consistent as of the restarted transaction. Cheers, Stu Stuart Halloway Clojure/core http://clojure.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 -- 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