Re: Radically simplified Emacs and SLIME setup
Phil Hagelberg p...@hagelb.org writes: Hi Phil, $ lein upgrade # == 0.6.3 $ lein plugin install swank-clojure 1.4.0-SNAPSHOT There is no Leiningen version 0.6.3--I'm assuming you're running 1.5.2? Ups, you are correct. ;-) Reflection warning, swank/util/io.clj:15 - call to java.lang.String ctor can't be resolved. It looks like there are still problems with suppressing output from the subprocess. I'll see if I can get that fixed soon. I have to say that this project uses a clojure 1.3.0 snapshot. Is that supposed to work? And if not, is there some workaround? If you upgrade to leiningen from git it will remove the *classpath* warning, but if you have other output like reflection warnings it's not going to work right now unless you can get rid of it all; sorry. Hopefully I'll have a fix soon. Do I get you right that the output is the problem that prevents me to get to the SLIME REPL, since you didn't say anything at all about that IllegalArgumentException? Bye, Tassilo -- You 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: extending types
On Thu, May 19, 2011 at 11:26 PM, Lachlan lachlan.kana...@gmail.com wrote: Just working through this, if we take your example above, what if I wanted to override the 'put' method rather than define a new one, since we don't have access to 'proxy-super'. For example making a map that enforces storage of dates in a string format - something like: (defprotocol DMap (put [this o1 o2]) (get-as-date [this o1])) (extend-type clojure.lang.PersistentArrayMap NPut (put [this o1 o2] (if (::datestore (meta this)) (super put o1 (format-date-to-string o2)) (super put o1 o2))) (get-as-date [this o1] (if (::datestore (meta this)) (parse-date (super get o1)) (super get o1))) and get will return the string formatted version or another example could be forcing all keys to be keywords, even if they are provided as a string or symbol, without having to write (assoc {} (keyword k) v) all the time. the other motivation would be to be able to throw exceptions on invalid input into a map or vector, rather than debugging involving 'why the hell has that map got an xxx in it!' when after much searching it turns out i've got some function arguments around the wrong way :) Several suggestions: First, you may want to solve some of these issues by providing your own functions (and possibly using protocols and extend-type to make them polymorphic) that do what you want. In Clojure, behavior (and decisions about what works with which objects) tends to be in functions, not the objects themselves. So you can make this for instance: (defn assoc-k [m k v] (let [k (if (keyword? k) k (keyword (str k)))] (assoc m k v))) For validation you could make an assoc-v that checks the map's metadata for a validation function and calls it on the key and value, then calls assoc. The validation function throws an exception if it doesn't like the kv pair. Or, if the maps will be in refs, atoms, or similarly, you can attach validators to those that check the whole map (and can enforce multi-key constraints). For the big guns, you can also use deftype on clojure.lang.Associative or clojure.lang.IPersistentMap to make map-like objects with overridden assoc and other methods. You tried that above, but hoping to extend PersistentArrayMap and call super. Instead, implement IPersistentMap and delegate by having an internal map object, e.g. (defn format-date-to-string [obj] (if (instance? java.util.Date obj) (str obj) obj)) (defn parse-date [obj] (if (string? obj) (try (java.util.Date. (java.util.Date/parse obj)) (catch IllegalArgumentException _ obj)) obj)) (defprotocol DMap (put [this k v]) (get-as-date [this k])) (deftype DateMap [m] clojure.lang.IPersistentMap ; implement methods to delegate to m ; and wrap return in (DateMap. ...) ; but maybe punt assoc to put and get to ; get-as-date instead. (assoc [this k v] (DateMap. ; (assoc m k (format-date-to-string v (assoc m k v))) (without [this k] (DateMap. (dissoc m k))) (assocEx [this k v] (DateMap. ; (.assocEx m k (format-date-to-string v (.assocEx m k v))) (iterator [this] (.iterator m)) (containsKey [this k] (.containsKey m k)) (entryAt [this k] (first {k (get this k)})) (count [this] (count m)) (cons [this [k v]] (assoc this k v)) (empty [this] (DateMap. (with-meta {} (meta m (equiv [this obj] (= m obj)) (seq [this] (seq (zipmap (keys m) (map this (keys m) (valAt [this k] (.valAt this k nil)) (valAt [this k not-found] (if-let [[_ v] (find m k)] ; (parse-date (m k not-found)) v not-found)) clojure.lang.IObj ; Let DateMap have metadata (meta [this] (meta m)) (withMeta [this md] (DateMap. (with-meta m md))) clojure.lang.IFn (invoke [this k] ; Make DateMap a function (get this k)) ; of its keys like normal maps (invoke [this k not-found] (get this k not-found)) DMap (put [this k v] (DateMap. (assoc m k (format-date-to-string v (get-as-date [this k] (parse-date (m k (extend-type clojure.lang.APersistentMap ; Should catch PersistentArrayMap, PersistentHashMap, etc. DMap (put [this k v] (assoc this k v)) (get-as-date [this k] (this k))) which works: = (def q (put {} :foo (java.util.Date.))) #'user/q = q {:foo #Date Thu May 19 22:44:10 PDT 2011} = (get-as-date q :foo) #Date Thu May 19 22:44:10 PDT 2011 = (def r (put (DateMap. {}) :foo (java.util.Date.))) #'user/r = r {:foo Thu May 19 22:44:37 PDT 2011} = (get-as-date r :foo) #Date Thu May 19 22:44:10 PDT 2011 (Try also storing other types of value in r, even with put, and retrieving them, even with get-as-date. Try even strings that aren't dates. Try calling the map as a function, or using get or a keyword, and using the optional not-found with each. Try attaching and reading metadata, or doing pretty much anything else commonly done with Clojure maps. I tested all of these things and they worked
Re: extending types
On Fri, May 20, 2011 at 2:54 AM, Ken Wesson kwess...@gmail.com wrote: = (def r (put (DateMap. {}) :foo (java.util.Date.))) #'user/r = r {:foo Thu May 19 22:44:37 PDT 2011} = (get-as-date r :foo) #Date Thu May 19 22:44:10 PDT 2011 Bah, copy and paste error. Test it and you'll find it works regardless. Somehow I got the result from (get-as-date q :foo) copied here, but with that value of :foo in r (get-as-date r :foo) yields 22:44:37. -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- You 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 stack
On Fri, May 20, 2011 at 12:26 AM, michele michelemen...@gmail.com wrote: It's not really the Emacs tools that are a problem, but the huge amount of web pages trying - with good intentions - to help you installing the Emacs-Clojure stack, but usually lacking some important detail. It feels like playing a jig-saw puzzle without being able to look at the picture on the box. Being new to Clojure and Emacs, you really have to be devoted and have a lot of spare time. In my experience, this is common to a) anything to do with Emacs, b) anything to do with Linux that isn't a big distro's own website-based help, and c) pretty much every other large, low-budget open source project, unfortunately. Hackers hate writing documentation aimed at n00bs, so they rush the job more often than not or else write only documentation that only hackers can understand, or both. At least when the tools are programming language tools the audience consists almost purely of hackers, but even then hackers that are n00bs to the particular thing, especially when it comes with a massive paradigm shift, may have problems. And emacs, in particular, comes with a massive paradigm shift. So does Clojure, if you're not *both* a Lisper *and* familiar with functionally-oriented languages along the lines of ML, Haskell, Scala, and Clojure. (I expect Schemers to have a significant leg up on everybody else. I use functionally oriented here to distinguish from languages that, while sometimes described as functional, have easy imperative/mutating use patterns as well -- Common Lisp, I'm looking at you.) So emacs PLUS Clojure ... Three paradigm shifts for the price of one. Fun. :) -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- You 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: Google Refine
It's a way older older version of clojure but it's in there. I've played around with it. You can always replace the jars (and include others such as support for Jython) and even add contrib. I've done that and it works just fine :) The one grief I had with GRefine is that once you create a custom facet you cannot sort by it :'( U -- You 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.3 Alpha 7
Looks like a ?bug? has crept into defrecord somewhere - I know that there is a limit to the number of params that a fn can take, but is it intentional that the same limit applies to the number of slots that a record can have ? : [jules@megalodon dada]$ java -jar ~/.m2/repository/org/clojure/clojure/1.3.0-alpha6/clojure-1.3.0-alpha6.jar Clojure 1.3.0-alpha6 user= (defrecord Foo [a b c d e f g h i j k l m n o p q r s t]) user.Foo user= [jules@megalodon dada]$ java -jar ~/.m2/repository/org/clojure/clojure/1.3.0-alpha7/clojure-1.3.0-alpha7.jar Clojure 1.3.0-alpha7 user= (defrecord Foo [a b c d e f g h i j k l m n o p q r s t]) CompilerException java.lang.RuntimeException: Can't specify more than 20 params, compiling:(NO_SOURCE_PATH:1) user= sorry to the bearer of bad tidings :-( Jules -- You 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
Silent failure of extend-type when used on an array type
The extend-type macro silently fails when used to extend an array type: = eval `(extend-type ~(class (into-array Object [42])) Xfer (look [this#] (aget this# 0)) (mutate* [this# f# args#] (aset this# (apply f# (aget this# 0) args#) 0 nil = (def foo (into-array Object [42])) #'user/foo = (seq foo) (42) = (mutate foo * 2) #CompilerException java.lang.IllegalArgumentException: No implementation of method: :mutate* of protocol: #'user/Xfer found for class: [Ljava.lang.Object; (NO_SOURCE_FILE:0) If you're curious what I was doing, I'm looking to slap together a little demonstration of data races screwing up invariants and the exact same (polymorphic) code not causing the same problem if refs are used instead -- hence a protocol to mutate a thread-unsafe mutable cell that can also be extended sensibly to refs (and, for that matter, atoms). -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- You 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
Simple thread-safety demo
This short program creates a polymorphic protocol that provides a unified interface for reading and for applying a function to mutable objects and extends it to refs and atoms while creating a Cell type that amounts to a volatile mutable variable. (look thingie) will return the value in all three cases and (mutate! thingie f args) does analogous to (swap! an-atom f args) in all three cases. Then it builds a function rand-xfers-conc! that creates X mutable objects of type Y, then starts Z threads that each perform W random transactions on random pairs of the mutables, then waits for the threads to finish and reports statistics on the outcome. In the process, it demonstrates protocols and protocol extension for abstraction, a simple mutable deftype, some concurrency tricks for making and awaiting large thread pools, gambler's ruin, AND the differing thread-safety and performance characteristics of volatile mutables, atoms, and refs. The mutables are created with integer values and the transactions consist of withdrawing a random amount from one account and depositing it in the other, with overdrawing disallowed, a per-transaction transfer maximum of 1, and a short delay between determining the amount and performing the transfer (to allow time for other transactions involving one of the same cells to be fairly likely, but not so likely as to make the case with refs take forever). Here are the results from one run with each type of mutable: = (rand-xfers-conc! #(ref 100) 100 100 1000) init-sum = 1 final-sum = 1 final-minimum = 0 nil = (rand-xfers-conc! #(atom 100) 100 100 1000) init-sum = 1 final-sum = 1 final-minimum = -330128 nil = (rand-xfers-conc! #(Cell. 100) 100 100 1000) init-sum = 1 final-sum = 14632 final-minimum = -211252 nil Each run started the accounts with a balance of 100 and each created 100 of these and then ran 1000 transactions in each of 100 simultaneous threads. With refs, the initial and final sum agree and no account becomes overdrawn. Transactional integrity is perfect. With atoms, the initial and final sum still agree -- each transaction adds an amount to one account and removes the same amount from another, and atom's swap! guarantees that there won't be any data races to updates to any individual atom, so none of the separate withdrawals and deposits can go missing, and since every withdrawal is paired with a matching deposit the total is invariant after all transactions have completed. However, accounts end up overdrawn, with the worst ending up over three hundred grand in the hole! What happened here? Atoms only protect against data races involving concurrent updates of the same atom. Nothing stops an account with $130 being seen by rand-xfer! as able to lose up to $130, so rand-xfer! decides to withdraw $70 from it, then the account having $90 withdrawn by another thread, leaving $40, and then rand-xfer! yanking out the $70 to leave it overdrawn by thirty bucks, for instance. With Cells, the results are worse by far: the final sum shows almost five thousand bucks created out of thin air, as *well* as accounts overdrawn by as much as two hundred grand. If banks had this poor transactional integrity in their computers, we'd have skyrocketing inflation. The cause here is the blatant data race between two updates to the same volatile: x is 40, thread a reads it as 40, thread b reads it as 40, thread a adds 30 to get 70, thread b subtracts 20 to get 20, thread a writes 70 to x, and thread b writes 20 to x. Thread a's addition of 40 to x went missing as a result of this race condition, but may still have been withdrawn successfully from some other account. Withdrawals can go missing too, and in this instance some must have since the net change in the total balance was positive. With atoms, the additions of 70 and -20 are done atomically (hence the name atom) so the read, addition, and subsequent write cannot get interleaved with a concurrent swap! in another thread, but Cells offer no such protection. Performance-wise, the Cells case takes a few seconds to execute on my hardware, the atoms case maybe a smidgen longer, and the refs case about half a minute. Refs perform significantly more slowly with the high level of contention artificially created by putting that 10ms delay in rand-xfer! because there end up being a lot of transaction retries -- one for every case where Cells and atoms generate an overdrawn account, and then some. However, slow and correct beats fast and wrong any day, so for transactions like these refs are absolutely the best choice -- nay, the only correct choice (bar explicit locking -- but see below). Without the 10ms delay in rand-xfer!, the atoms case usually produces a nonnegative final minimum balance, but the data race still exists; the error rate is just too low for overdrafts to occur very often. But in a real-world system, even data races allowing invariants like (not-any? neg? balances) to be violated only at the low
Re: Clojure 1.3 Alpha 7
On Fri, May 20, 2011 at 6:43 AM, Jules jules.gosn...@gmail.com wrote: Looks like a ?bug? has crept into defrecord somewhere - I know that there is a limit to the number of params that a fn can take, but is it intentional that the same limit applies to the number of slots that a record can have ? [jules@megalodon dada]$ java -jar ~/.m2/repository/org/clojure/clojure/1.3.0-alpha6/clojure-1.3.0-alpha6.jar Clojure 1.3.0-alpha6 user= (defrecord Foo [a b c d e f g h i j k l m n o p q r s t]) user.Foo user= [jules@megalodon dada]$ java -jar ~/.m2/repository/org/clojure/clojure/1.3.0-alpha7/clojure-1.3.0-alpha7.jar Clojure 1.3.0-alpha7 user= (defrecord Foo [a b c d e f g h i j k l m n o p q r s t]) CompilerException java.lang.RuntimeException: Can't specify more than 20 params, compiling:(NO_SOURCE_PATH:1) user= It's actually worse than that! There are exactly twenty slots there, so even though it's saying can't specify more than 20 it's actually choking on any amount more than NINETEEN. -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- You 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.lang.PersistentVector cannot be cast to java.lang.String
Hello, I would like to open an excel file from multipart data without saving it (forbidden by Google Appengine). I have adapted the incanter's read-xls which reads from actual files to read-xls-stream which takes an object of the same kind that with-open provides. I wanted to write something like the following but I get the error message: clojure.lang.PersistentVector cannot be cast to java.lang.String. I don't really understand the mismatch and how to convert one type to the other... (use [appengine-magic.multipart-params :only (wrap-multipart-params)]) (defn retailer-stock-update [] (wrap-multipart-params (fn [req] (let [xls (get (:params req) stock-xls)] (with-in-str [str (:bytes xls)] (read-xls-stream str)) As far as I have understood, (:bytes xls) is seen as a java byte array, since (class (:bytes xls)) displays class [B, but I don't get how it is related to the previous error message. I guess I sould manually convert (:bytes xls) to the type with-in-str wants but I don't know how. I have given a look to http://code.google.com/appengine/kb/java.html#fileforms but I guess clojure can do without explicit call to FileItemStream and FileItemIterator. Anyway, I didn't manage to deal with it either. Could you give me a clue? Thanks in advance, Vincent -- You 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 stack
On May 19, 2011, at 7:42 PM, Korny Sietsma wrote: Experienced developers (who are likely to grok clojure) probably already use one of ant / rake / maven / sbt etc. Experienced with what? is the question. Those coming from the Lisp world, who are likely both to grok and to be ready to love Clojure, won't necessarily know anything about those tools. Even the IDE users probably understand the need to dip into the command-line for things like building deployable artifacts. The need for the dip isn't the issue, IMHO, it's what you fall into when you dip -- that is, it's the complexity of what you have to dip into, how easy it is to figure out if it's all new to you, how much guidance is provided, etc. -Lee -- You 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 stack
Lee Spector lspec...@hampshire.edu wrote: On May 19, 2011, at 7:42 PM, Korny Sietsma wrote: Experienced developers (who are likely to grok clojure) probably already use one of ant / rake / maven / sbt etc. Experienced with what? is the question. Those coming from the Lisp world, who are likely both to grok and to be ready to love Clojure, won't necessarily know anything about those tools. Ditto for experience platform developers where the platform in question isn't the JVM. Even the IDE users probably understand the need to dip into the command-line for things like building deployable artifacts. The need for the dip isn't the issue, IMHO, it's what you fall into when you dip -- that is, it's the complexity of what you have to dip into, how easy it is to figure out if it's all new to you, how much guidance is provided, etc. This all actually ties back to my complaint that Simple things aren't simple. Working on a web problem set is a simple thing. Getting to a point where you can do that with Clojure isn't. -- Sent from my Android tablet with K-9 Mail. Please excuse my brevity. -- You 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 stack
On May 19, 2011, at 7:43 PM, mike.w.me...@gmail.com wrote: The download the massive IDE path seems to presume that a newcomer actually needs something more than a simple REPL in order to get started. I'd claim that's wrong - at least in a world where any computer you'd run clojure on can multitask and display multiple windows. Yes, a system where the editor and REPL are tightly coupled is much more productive, but that's at a micro scale. Running a simple editor in one window and a REPL in a shell/console window in another will do for starters - it'll still be a lot faster than a typical edit/compile/run cycle, and should be sufficient to get a feel for how Clojure is a win at the macro scale. I agree that there's a sweet spot for newcomers here, where one uses a simple REPL (possibly invoked with lein) and an editor that's not tightly coupled, which should make it easier to provide a unified and idiot-proof download/install procedure. But I do think that you need an editor with a few essential features, at very least bracket matching and Clojure-aware auto-indenting. Last I checked JEdit (which you mentioned later in your message) does not have Clojure-aware auto-indenting, but I agree that if it did then this would be an attractive package for many newcomers. I think there are a couple of other 95% of the way there approaches out there for hitting this sweet spot (with different, small but significant flaws in each, as of the last time I checked). -Lee -- You 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 stack
On Fri, May 20, 2011 at 9:43 AM, Lee Spector lspec...@hampshire.edu wrote: I agree that there's a sweet spot for newcomers here, where one uses a simple REPL (possibly invoked with lein) and an editor that's not tightly coupled, which should make it easier to provide a unified and idiot-proof download/install procedure. But I do think that you need an editor with a few essential features, at very least bracket matching and Clojure-aware auto-indenting. Last I checked JEdit (which you mentioned later in your message) does not have Clojure-aware auto-indenting, but I agree that if it did then this would be an attractive package for many newcomers. The JEdit mode for Clojure has auto-indenting and bracket matching and it works just fine for me. If you weren't able to get that to work did you try contacting the maintainer of the mode? 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: clojure.lang.PersistentVector cannot be cast to java.lang.String
On Fri, May 20, 2011 at 9:22 AM, Vincent Liard vincent.li...@free.frwrote: (defn retailer-stock-update [] (wrap-multipart-params (fn [req] (let [xls (get (:params req) stock-xls)] (with-in-str [str (:bytes xls)] (read-xls-stream str)) You usage of with-in-str is not correct, you're passing a vector where it expects a string. I don't know enough about appengine-magic to comment on the rest. 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: clojure.lang.PersistentVector cannot be cast to java.lang.String
On Fri, May 20, 2011 at 9:22 AM, Vincent Liard vincent.li...@free.fr wrote: (defn retailer-stock-update [] (wrap-multipart-params (fn [req] (let [xls (get (:params req) stock-xls)] (with-in-str [str (:bytes xls)] (read-xls-stream str)) As far as I have understood, (:bytes xls) is seen as a java byte array, since (class (:bytes xls)) displays class [B That is correct. So try replacing the last two lines with: (with-open [str (ByteArrayInputStream. (:bytes xls))] (read-xls-stream str)) The exception is because with-in-str is expecting a single string argument, not a binding vector; with-in-str temporarily rebinds *in* to read from a string rather than binding an arbitrary stream. -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- You 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 stack
On May 20, 2011, at 9:48 AM, David Nolen wrote: The JEdit mode for Clojure has auto-indenting and bracket matching and it works just fine for me. If you weren't able to get that to work did you try contacting the maintainer of the mode? Not that I recall but I did mention it in a discussion on this list back in March. Yes, bracket matching works in JEdit but at least as far as I can see (and I just tried the latest development build) it doesn't have what I consider to be Clojure-aware automatic indenting -- that is, where it indents according to standard Lisp conventions, as emacs lisp modes do, and Counterclockwise does (almost :-), and MCLIDE and TextMate clojure modes do, etc. Am I just missing something? I've tried Edit Indent Indent lines, and also the Tab key and various other things I could think of. -Lee -- You 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.lang.PersistentVector cannot be cast to java.lang.String
At Fri, 20 May 2011 09:55:22 -0400, David Nolen wrote: On Fri, May 20, 2011 at 9:22 AM, Vincent Liard vincent.li...@free.fr wrote: [...] (with-in-str [str (:bytes xls)] (read-xls-stream str)) You usage of with-in-str is not correct, you're passing a vector where it expects a string. I don't know enough about appengine-magic to comment on the rest. You're right, thanks. I noticed this too late. -- You 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 stack
On Fri, May 20, 2011 at 10:01 AM, Lee Spector lspec...@hampshire.eduwrote: On May 20, 2011, at 9:48 AM, David Nolen wrote: The JEdit mode for Clojure has auto-indenting and bracket matching and it works just fine for me. If you weren't able to get that to work did you try contacting the maintainer of the mode? Not that I recall but I did mention it in a discussion on this list back in March. Yes, bracket matching works in JEdit but at least as far as I can see (and I just tried the latest development build) it doesn't have what I consider to be Clojure-aware automatic indenting -- that is, where it indents according to standard Lisp conventions, as emacs lisp modes do, and Counterclockwise does (almost :-), and MCLIDE and TextMate clojure modes do, etc. Am I just missing something? I've tried Edit Indent Indent lines, and also the Tab key and various other things I could think of. -Lee I have no idea how to make it work for you since it just worked for me. It would helpful for yourself and others if you contacted the maintainer explained your issue and discovered the source of problem. It would be even more helpful if you updated the Confluence Getting Started wiki on JEdit (that I started back in March) for others so that they can avoid such pitfalls. 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: clojure.lang.PersistentVector cannot be cast to java.lang.String
At Fri, 20 May 2011 09:59:35 -0400, Ken Wesson wrote: On Fri, May 20, 2011 at 9:22 AM, Vincent Liard vincent.li...@free.fr wrote: (defn retailer-stock-update [] (wrap-multipart-params (fn [req] (let [xls (get (:params req) stock-xls)] (with-in-str [str (:bytes xls)] (read-xls-stream str)) As far as I have understood, (:bytes xls) is seen as a java byte array, since (class (:bytes xls)) displays class [B That is correct. So try replacing the last two lines with: (with-open [str (ByteArrayInputStream. (:bytes xls))] (read-xls-stream str)) The exception is because with-in-str is expecting a single string argument, not a binding vector; with-in-str temporarily rebinds *in* to read from a string rather than binding an arbitrary stream. Thank you! I eventually noticed my error on the with-in-str call, but I would never have found ByteArrayInputStream. The clojure newcomer should be ready to learn java :) Many thanks for your help! Vincent -- You 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.lang.PersistentVector cannot be cast to java.lang.String
On Fri, May 20, 2011 at 10:32 AM, Vincent Liard vincent.li...@free.fr wrote: At Fri, 20 May 2011 09:59:35 -0400, Ken Wesson wrote: The exception is because with-in-str is expecting a single string argument, not a binding vector; with-in-str temporarily rebinds *in* to read from a string rather than binding an arbitrary stream. Thank you! I eventually noticed my error on the with-in-str call, but I would never have found ByteArrayInputStream. The clojure newcomer should be ready to learn java :) Many thanks for your help! You're welcome. -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- You 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 group in DFW area
Thanks everyone for attending. Our next meeting is scheduled for Our next meeting is scheduled for May 31th 630PM - 900PM @ Rubedo, inc. 14580 Beltwood Pkwy E Suite 103 Farmers Branch, TX 75244 (wifi available) there will be pizza and sodas, so bring your clojure questions and your appetite. Reply in this thread if you will be attending so that I can get a head count for pizza. On May 16, 12:41 pm, ch...@rubedoinc.com ch...@rubedoinc.com wrote: Meeting tonight, see you there ! Our next meeting is scheduled for May 16th 630PM - 900PM @ Rubedo, inc. 14580 Beltwood Pkwy E Suite 103 Farmers Branch, TX 75244 (wifi available) On May 4, 11:20 am, ch...@rubedoinc.com ch...@rubedoinc.com wrote: Thanks everyone for attending the first meeting. It was great to talk clojure with some like minded people who are excited by the possibilities ! Our next meeting is scheduled for May 16th 630PM - 900PM @ Rubedo, inc. 14580 Beltwood Pkwy E Suite 103 Farmers Branch, TX 75244 (wifi available) Right now, we will try for two meetings each month. In the beginning, these will be mostly hack nights. As the group matures, we will look at doing presentations / talks on Clojure. As most of the group is relatively new to Clojure, we decided to start with thehttp://projecteuler.net/problemsas a way to get familiar with the language and have some common solutions to discuss. At our next meeting, we will bring our solutions for problems 1-10 and discuss how we went about solving them. All are welcome ! On Apr 25, 9:08 pm, Christopher Redinger ch...@clojure.com wrote: ch...@rubedoinc.com wrote: Rubedo, inc. 14580 Beltwood Pkwy E Suite 103 Farmers Branch, TX 75244 When: 630PM Monday May 2nd What: Clojure Interest Group Topic: 1st meeting, what our goals are, and how to take over the world with Clojure Hi Chris! Thanks for offering to host the group. I've added a link to this thread on the Clojure User Groups page:http://dev.clojure.org/display/community/Clojure+User+Groups. Hopefully to help people who might be looking. We can update the link to something with a little more information if you get a page set up somewhere. Also, if you choose to go through Meetup, they have provided us with a code that gives a discount to Clojure groups. See the above page for more information. Thanks again, and let me know if there's anything Clojure/core can help you out with! Thanks, Chris -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure group in DFW area
I'm planning to be there. Alex -- You 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
New to Clojure
I am trying to help with an existing project and have no developer notes on the application. I'm trying to use Lein to build the project.clj project file. Within the Clojure build file (named project.clj), the dependencies for the project are specified. Two of the dependencies are developer build SNAPSHOTS, rather than release build libraries. The 'work:work:jar:0.2.4-SNAPSHOT' build is missing and unable to resolve. The actual error message is included below. Could you provide any insight into the purpose of the 'work:work:jar:0.2.4- SNAPSHOT' developer build? Perhaps where I could locate the subsequent release build of this library? Or was this perhaps a temporary build that was used for some purpose, but not needed anymore even? The other SNAPSHOT appears to be used for the purpose of date/time handling; it is clj-time:clj-time:0.3.0-SNAPSHOT. It is producing the warning included here: [INFO] snapshot clj-time:clj-time:0.3.0- SNAPSHOT: checking for updates from snapshots [WARNING] repository metadata for: 'snapshot clj-time:clj-time:0.3.0-SNAPSHOT' could not be retrieved from repository: snapshots due to an error: Error transferring file. Any help, tips, or insight would be very much appreciated on this one! Is there is a more appropriate group to address this question? Thanks so much! Dudaroo -- You 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 to Clojure
In the clojars repository, looks like the most recent versions are: [work 0.1.2-SNAPSHOT] http://clojars.org/work [clj-time 0.3.0] http://clojars.org/clj-time On Fri, May 20, 2011 at 1:01 PM, dudaroo duda...@gmail.com wrote: I am trying to help with an existing project and have no developer notes on the application. I'm trying to use Lein to build the project.clj project file. Within the Clojure build file (named project.clj), the dependencies for the project are specified. Two of the dependencies are developer build SNAPSHOTS, rather than release build libraries. The 'work:work:jar:0.2.4-SNAPSHOT' build is missing and unable to resolve. The actual error message is included below. Could you provide any insight into the purpose of the 'work:work:jar:0.2.4- SNAPSHOT' developer build? Perhaps where I could locate the subsequent release build of this library? Or was this perhaps a temporary build that was used for some purpose, but not needed anymore even? The other SNAPSHOT appears to be used for the purpose of date/time handling; it is clj-time:clj-time:0.3.0-SNAPSHOT. It is producing the warning included here: [INFO] snapshot clj-time:clj-time:0.3.0- SNAPSHOT: checking for updates from snapshots [WARNING] repository metadata for: 'snapshot clj-time:clj-time:0.3.0-SNAPSHOT' could not be retrieved from repository: snapshots due to an error: Error transferring file. Any help, tips, or insight would be very much appreciated on this one! Is there is a more appropriate group to address this question? Thanks so much! Dudaroo -- You 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
Passing environment configuration parameters to a Clojure web app
Hello, I like to have the configuration parameters of my webapps not being bundled in resource files in my webapp(*). So that my webapp can be packaged once and for all for a given version, and not be repackaged for each deployment target. The technique I'm generally using when doing this, which is the most agnostic (IMHO) wrt where the webapp will run, is to pass via a JNDI parameter the absolute path to the configuration file having the values relevant to the execution environment. By doing so, the team responsible for managing the webapp has the ability to specify where the configuration file should live. For example, if my webapp must call some remote xml-rpc service, then the URL of the service will change from environment to environment (not the same for testing, pre-production, production, for example). So now my question : is there already somewhere in the ring ecosystem, or elsewhere, a package which already provides this as well as perhaps other facilities to still enable to painlessly use it in conjunction with unit and/or integration testing, etc. ? Thanks in advance, (*) : recent discussions / readings have, tho, somehow started to make me doubt about the dogma around my approach. For example, currently, Amazon Elastik Beanstalk seems to promote uploading wars created specifically for a platform (there's not the ability to bootstrap the webapp but from its own embedded resources, AFAIK). -- Laurent -- You 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 to Clojure
Hi, See my notes below: On Fri, 20 May 2011 10:01:42 -0700 (PDT) dudaroo duda...@gmail.com wrote: I am trying to help with an existing project and have no developer notes on the application. I'm trying to use Lein to build the project.clj project file. Within the Clojure build file (named project.clj), the dependencies for the project are specified. Two of the dependencies are developer build SNAPSHOTS, rather than release build libraries. The 'work:work:jar:0.2.4-SNAPSHOT' build is missing and unable to resolve. The actual error message is included below. Could you provide any insight into the purpose of the 'work:work:jar:0.2.4- SNAPSHOT' developer build? Perhaps where I could locate the subsequent release build of this library? Or was this perhaps a temporary build that was used for some purpose, but not needed anymore even? Could be something specific to your project, you will find a work/work lib on clojars but its version is 1.2-SNAPSHOT: http://clojars.org/work Look at the code on github: http://github.com/clj-sys/work To see if it's the same thing. The other SNAPSHOT appears to be used for the purpose of date/time handling; it is clj-time:clj-time:0.3.0-SNAPSHOT. It is producing the warning included here: [INFO] snapshot clj-time:clj-time:0.3.0- SNAPSHOT: checking for updates from snapshots [WARNING] repository metadata for: 'snapshot clj-time:clj-time:0.3.0-SNAPSHOT' could not be retrieved from repository: snapshots due to an error: Error transferring file. On Clojars search for clj-time. There is a 0.3.0 version (not a snapshot): http://clojars.org/clj-time You may need to upgrade and retest things. Any help, tips, or insight would be very much appreciated on this one! Is there is a more appropriate group to address this question? Thanks so much! Dudaroo -- Luc P. The rabid Muppet -- You 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 to Clojure
Look at the code on github: http://github.com/clj-sys/work http://github.com/clj-sys/workThis has moved to: https://github.com/getwoven/work You might also ask the maintainers of this project if they would be able to upload more recent versions to clojars. - Mark http://github.com/clj-sys/work On Fri, May 20, 2011 at 1:44 PM, Luc Prefontaine lprefonta...@softaddicts.ca wrote: Hi, See my notes below: On Fri, 20 May 2011 10:01:42 -0700 (PDT) dudaroo duda...@gmail.com wrote: I am trying to help with an existing project and have no developer notes on the application. I'm trying to use Lein to build the project.clj project file. Within the Clojure build file (named project.clj), the dependencies for the project are specified. Two of the dependencies are developer build SNAPSHOTS, rather than release build libraries. The 'work:work:jar:0.2.4-SNAPSHOT' build is missing and unable to resolve. The actual error message is included below. Could you provide any insight into the purpose of the 'work:work:jar:0.2.4- SNAPSHOT' developer build? Perhaps where I could locate the subsequent release build of this library? Or was this perhaps a temporary build that was used for some purpose, but not needed anymore even? Could be something specific to your project, you will find a work/work lib on clojars but its version is 1.2-SNAPSHOT: http://clojars.org/work Look at the code on github: http://github.com/clj-sys/work To see if it's the same thing. The other SNAPSHOT appears to be used for the purpose of date/time handling; it is clj-time:clj-time:0.3.0-SNAPSHOT. It is producing the warning included here: [INFO] snapshot clj-time:clj-time:0.3.0- SNAPSHOT: checking for updates from snapshots [WARNING] repository metadata for: 'snapshot clj-time:clj-time:0.3.0-SNAPSHOT' could not be retrieved from repository: snapshots due to an error: Error transferring file. On Clojars search for clj-time. There is a 0.3.0 version (not a snapshot): http://clojars.org/clj-time You may need to upgrade and retest things. Any help, tips, or insight would be very much appreciated on this one! Is there is a more appropriate group to address this question? Thanks so much! Dudaroo -- Luc P. The rabid Muppet -- You 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.3 Alpha 7
In the alpha7 release the defrecord macro was changed to generate a couple of auxiliary functions (for a record R) named map-R and -R. The first takes a map and returns a function of its contents. The second takes the same number of arguments as the record constructor. It's the definition of this second function that is reporting an error. It's easy enough to fix, but I guess the question is should it be fixed? That is, do people define records with 19+ fields? Does this pose a problem for existing code? :F -- You 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.3 Alpha 7
Hi, What's the incremental runtime cost of increasing the max number of fields to 40? :-) Las sent from my mobile device On May 20, 2011 7:55 PM, Fogus mefo...@gmail.com wrote: In the alpha7 release the defrecord macro was changed to generate a couple of auxiliary functions (for a record R) named map-R and -R. The first takes a map and returns a function of its contents. The second takes the same number of arguments as the record constructor. It's the definition of this second function that is reporting an error. It's easy enough to fix, but I guess the question is should it be fixed? That is, do people define records with 19+ fields? Does this pose a problem for existing code? :F -- You received this message because you are subscribed to the Google Groups Clojure group. To p... -- You 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 stack
On May 20, 12:03 am, Ken Wesson kwess...@gmail.com wrote: On Fri, May 20, 2011 at 12:26 AM, michele michelemen...@gmail.com wrote: It's not really the Emacs tools that are a problem, but the huge amount of web pages trying - with good intentions - to help you installing the Emacs-Clojure stack, but usually lacking some important detail. In my experience, this is common to a) anything to do with Emacs, b) anything to do with Linux that isn't a big distro's own website-based help, and c) pretty much every other large, low-budget open source project, unfortunately. In general this may be true, but it's particularly frustrating with swank because the docs are actually pretty good; (I think; if they are lacking in some way please speak up!) it's just that they are often ranked by google below out-of-date blog posts. Additionally, it's very easy to improve the official docs, but for some reason people don't bother to try. I do not understand why. -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: Clojure 1.3 Alpha 7
On Fri, May 20, 2011 at 1:55 PM, Fogus mefo...@gmail.com wrote: In the alpha7 release the defrecord macro was changed to generate a couple of auxiliary functions (for a record R) named map-R and -R. The first takes a map and returns a function of its contents. The second takes the same number of arguments as the record constructor. It's the definition of this second function that is reporting an error. It's easy enough to fix, but I guess the question is should it be fixed? That is, do people define records with 19+ fields? Does this pose a problem for existing code? :F Java allows classes to define up to 255 fields right? Seems like defrecord/deftype should at least support that limit. The use case would be for certain code generation scenarios. 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: Clojure 1.3 Alpha 7
Use Case: Auto-generated record - relational mapping? Tables with more than 19 columns is not unheard of. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com 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 stack
To clarify, David, when you say it just worked you mean that when you select Edit Indent Indent lines then the line containing the insertion point is moved (left or right, as appropriate) to conform to standard Lisp indentation conventions with respect to the code above it (e.g. with respect to the position that you are within an s-expression, etc.)? I note that there is some variation in what is the standard Lisp indentation convention in some cases, e.g. in certain special forms as opposed to ordinary s-expressions, but mainly I want to know what it is that you do to make it work and roughly what it is that then happens. I've had similar conversations with people in the Bluefish community and it turned out that for at least one person auto-indenting just meant lining up with the first non-blank line of the preceding line, without regard to the Lisp syntax. I kept saying that it wasn't working but it turned out that it was -- it's just that it wasn't what I meant by Clojure-aware auto-indenting. Assuming that I understand what you mean by auto-indenting, and that you invoke it with Edit Indent Indent lines, does this also work for you for all lines of a highlighted selection? In other words, I'm not yet sure if I'm actually experiencing a problem or if I'm just looking for a feature that isn't there. It would help me to know a little more about what you do and what you see when it just works, so that I'll have a better idea of what I should ask/tell the maintainer. Thanks, -Lee -- You 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.3 Alpha 7
That's right. Database tables are much flatter than the typical object composition, which you can do after you bring in a tuple into a record. Here's probably where this limitation in Clojure hurts the most, even when tables are fully normalized. On May 20, 11:37 am, pmbauer paul.michael.ba...@gmail.com wrote: Use Case: Auto-generated record - relational mapping? Tables with more than 19 columns is not unheard of. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com 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 stack
On Fri, May 20, 2011 at 3:04 PM, Lee Spector lspec...@hampshire.edu wrote: To clarify, David, when you say it just worked you mean that when you select Edit Indent Indent lines then the line containing the insertion point is moved (left or right, as appropriate) to conform to standard Lisp indentation conventions with respect to the code above it (e.g. with respect to the position that you are within an s-expression, etc.)? Ah I thought you were talking about proper automatic indentation as you enter in code not selective *re-indentation*. As far as I can tell in the existing Clojure tools there are only varying degrees of interpretation as to what constitutes proper Lisp formatting. But I've found this to be the case regardless of what combination of programming language + editing tool I use. 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: Clojure 1.3 Alpha 7
I have a potential fix that handles the extra -R parameters. However, there are some existing caveats: 1. The 20+ args path is much slower than the 20 args path. This is a limitation that may not go away unless the 20 function args limitation does. The speed difference comes from the ability to perform (R. ~@args) in the 20 path and the need for (into record-of-20-args built-map-of- remaining-args) in the 20+ path. (note paths determined at compile time) 2. Any extra values passed to -R in the 20+ case are lost. e.g. (defrecord R [a ... u]) (-R 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22) ;= #user.R{:a 1, :b 2, :c 3, :d 4, :e 5, :f 6, :g 7, :h 8, :i 9, :j 10, :k 11, :l 12, :m 13, :n 14, :o 15, :p 16, :q 17, :r 18, :s 19, :u 21, :t 20} 22 is missing. Thoughts? -- You 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 to Clojure
Thanks Mark... It seems that it is still not resolving correctly though... I changed the line in the project.clj file from: [work 0.2.4-SNAPSHOT] to [work 0.1.2-SNAPSHOT] Intuitively, I would've expected to have increased the version number as opposed to changing it to a lower number. However, this is indeed the version posted at the URL's you've provided below. Here is the current project.clj file. The only change I've made is the version of the work snapshot noted above. $ more project.clj (defproject recruitassist 1.0.0-SNAPSHOT :description FIXME: write :dependencies [[org.clojure/clojure 1.2.0] [org.clojure/clojure-contrib 1.2.0] [postgresql/postgresql 9.0-801.jdbc4] [clojureql 1.0.0] [compojure 0.5.3] [ring/ring-jetty-adapter 0.3.1] [org.clojars.gukjoon/ojdbc 1.4] [joda-time 1.6] [clj-time 0.3.0-SNAPSHOT] [work 0.1.2-SNAPSHOT] [clojure-csv 1.2.4]] :dev-dependencies [[swank-clojure 1.2.1]] :source-path src/main/clojure :test-path test/main/clojure :java-source-path src/main/java :java-test-path test/main/java :aot [recruitassist.core] :repositories {snapshots http://mvn.getwoven.com/repos/woven- public-snapshots releases http://mvn.getwoven.com/repos/woven- public-releases}) Running lein.sh deps, however continues to produce errors in resolving the dependencies... $ lein.sh deps [INFO] snapshot clj-time:clj-time:0.3.0-SNAPSHOT: checking for updates from releases [WARNING] repository metadata for: 'snapshot clj-time:clj-time:0.3.0- SNAPSHOT' could not be retrieved from repository: releases due to an error: Error transferring file [INFO] Repository 'releases' will be blacklisted [INFO] snapshot clj-time:clj-time:0.3.0-SNAPSHOT: checking for updates from snapshots [WARNING] repository metadata for: 'snapshot clj-time:clj-time:0.3.0- SNAPSHOT' could not be retrieved from repository: snapshots due to an error: Error transferring file [INFO] Repository 'snapshots' will be blacklisted Downloading: clj-sys/plumbing/0.1.2-SNAPSHOT/plumbing-0.1.2- SNAPSHOT.pom from clojure-snapshots Downloading: clj-sys/plumbing/0.1.2-SNAPSHOT/plumbing-0.1.2- SNAPSHOT.pom from clojars Downloading: clj-sys/plumbing/0.1.2-SNAPSHOT/plumbing-0.1.2- SNAPSHOT.pom from central Downloading: clj-sys/plumbing/0.1.2-SNAPSHOT/plumbing-0.1.2- SNAPSHOT.jar from clojure-snapshots Downloading: clj-sys/plumbing/0.1.2-SNAPSHOT/plumbing-0.1.2- SNAPSHOT.jar from clojars Downloading: clj-sys/plumbing/0.1.2-SNAPSHOT/plumbing-0.1.2- SNAPSHOT.jar from central An error has occurred while processing the Maven artifact tasks. Diagnosis: Unable to resolve artifact: Missing: -- 1) clj-sys:plumbing:jar:0.1.2-SNAPSHOT Try downloading the file manually from the project website. Then, install it using the command: mvn install:install-file -DgroupId=clj-sys -DartifactId=plumbing -Dversion=0.1.2-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file Alternatively, if you host your own repository you can deploy the file there: mvn deploy:deploy-file -DgroupId=clj-sys -DartifactId=plumbing - Dversion=0.1.2-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file - Durl=[url] -DrepositoryId=[id] Path to dependency: 1) org.apache.maven:super-pom:jar:2.0 2) work:work:jar:0.1.2-SNAPSHOT 3) clj-sys:plumbing:jar:0.1.2-SNAPSHOT -- 1 required artifact is missing. for artifact: org.apache.maven:super-pom:jar:2.0 from the specified remote repositories: clojure (http://build.clojure.org/releases), releases (http://mvn.getwoven.com/repos/woven-public-releases), clojars (http://clojars.org/repo/), clojure-snapshots (http://build.clojure.org/snapshots), snapshots (http://mvn.getwoven.com/repos/woven-public-snapshots), central (http://repo1.maven.org/maven2) Exception in thread main Unable to resolve artifact: Missing: -- 1) clj-sys:plumbing:jar:0.1.2-SNAPSHOT Try downloading the file manually from the project website. Then, install it using the command: mvn install:install-file -DgroupId=clj-sys -DartifactId=plumbing -Dversion=0.1.2-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file Alternatively, if you host your own repository you can deploy the file there: mvn deploy:deploy-file -DgroupId=clj-sys -DartifactId=plumbing - Dversion=0.1.2-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file - Durl=[url] -DrepositoryId=[id] Path to dependency: 1) org.apache.maven:super-pom:jar:2.0 2) work:work:jar:0.1.2-SNAPSHOT 3) clj-sys:plumbing:jar:0.1.2-SNAPSHOT -- 1 required artifact is missing. for artifact: org.apache.maven:super-pom:jar:2.0 from the specified remote repositories: clojure (http://build.clojure.org/releases), releases (http://mvn.getwoven.com/repos/woven-public-releases), clojars (http://clojars.org/repo/),
Re: Clojure stack
On May 20, 2011, at 3:30 PM, David Nolen wrote: Ah I thought you were talking about proper automatic indentation as you enter in code not selective *re-indentation*. As far as I can tell in the existing Clojure tools there are only varying degrees of interpretation as to what constitutes proper Lisp formatting. But I've found this to be the case regardless of what combination of programming language + editing tool I use. David Ah -- okay, so in your terminology I guess I mean that it's Clojure-aware re-indenting that I think is a base-line requirement for a Clojure editor in the sweet spot of functionality that's necessary for non-trivial work but nonetheless simple enough, I hope, to be a target for a straightforward and relatively foolproof download/install process. Leiningen plus a simple-to-download editor with Clojure-aware RE-indenting and bracket matching would, I think, land in this sweet spot, providing a REPL and an editor and even easy project management via lein. It wouldn't provide other nice IDE features, but I think it wold be very helpful to have something like this. The reason that I think that this re-indenting feature is so important is that I've found that it's often the most effective way to spot simple coding errors: ask the editor to indent things appropriately and if something looks odd it's because the syntax isn't what you thought it was. The helps me quite a bit even after decades of Lisp programming, and I've found it to be really valuable in a teaching context. FWIW reasonable versions of this feature are available for Clojure in (at least) emacs, Eclipse/Counterclockwise, MCLIDE, NetBeans/Enclojure, TextMate, ..., but in my experience all of these are somewhat outside of the sweet spot for other reasons. And some version of this feature is available in most other Lisp/Scheme environments (all that I've worked in, I think -- I've come to think of it as completely standard and necessary for Lisp coding). The implementations that I listed don't all agree on what the correct indentation is, but they all have some version of this feature. BTW from what I can tell JEdit doesn't even do reasonable automatic indentation as you enter code in the first place. If I type (defn foo and hit return the cursor ends up under the second o in foo, and that seems pretty weird. If I type (conj '(a b c) and hit return it lines up under the a which is even odder -- some would say it should end up under the single quote (that'd be my vote in this situation), while some would put it under the o or the n, but I don't see any rationale for it being under the a. BTW also I mentioned MCLIDE above and I have to say that that's looking really wonderful to me these days, providing the stuff I mentioned above in a package with trivial download/setup and also many nice IDE features (including my all-time favorite feature, arglist-on-space). Clojure support is now fully baked in. I *think* (but haven't yet had the time to verify) that it should be pretty easy to integrate MCLIDE work with leiningen based projects, just by using lein from the command line and using lein classpath to get the info to paste into MCLIDE's launch scripts so that code run within MCLIDE finds everything. (Actually I think this might take a little tweaking but that it'll be relatively easy to automate...). The one big downside is that this only runs in Mac OS X. -Lee -- You 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 stack
Hi On 20 May 2011 21:04, Lee Spector lspec...@hampshire.edu wrote: To clarify, David, when you say it just worked you mean that when you select Edit Indent Indent lines then the line containing the insertion point is moved (left or right, as appropriate) to conform to standard Lisp indentation conventions with respect to the code above it (e.g. with respect to the position that you are within an s-expression, etc.)? I note that there is some variation in what is the standard Lisp indentation convention in some cases, e.g. in certain special forms as opposed to ordinary s-expressions, but mainly I want to know what it is that you do to make it work and roughly what it is that then happens. I've just given it a try now. I went here: http://clojure02.managed.contegix.com/display/doc/Getting+Started+with+JEdit Then I installed jedit. I'm using Ubuntu, so I just typed apt-get install jedit and it installed without complaint. Then I tried to install the clojure and clojureshell plugins, but that failed because the version of jedit was slightly too old. (It's an old version of Ubuntu, so not too surprising.) The syntax highlighting and indentation seems to be completely separate from the repl support, so I disabled the broken plugins, downloaded the clojure.xml file from https://github.com/djspiewak/jedit-modes/raw/master/clojure.xml and put it into my ~/.jedit/modes directory, after which I edited the ~/.jedit/modes/catalog file as mentioned on the getting started page. After that I closed and reopened jEdit. Not sure if that was necessary. Then I created a file called test.clj and opened it with jEdit. At the bottom of the window I see (clojure,none,UTF-8). If I type in some clojure code it seems to be indented OK when I press Enter, although it seems to be a constant 2 space indent instead of depending on the particular form. Also, if I mangle the indentation on a bunch of code I can click on Edit|Indent|Indent Lines to indent the line where the cursor is, or I can e.g. select all and then Edit|Indent|Indent Lines to indent the whole lot the same way it does while entering the code manually. So maybe the problem you're having is that jEdit can't find the clojure.xml mode file? This is the first time I've ever tried jEdit, so if the above doesn't help, sorry, I can help you :) -- 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: New to Clojure
A couple things going on here, I think: First, it looks like maven is having problems communicating with the Woven repositories (snapshots http://mvn.getwoven.com/repos/woven-public-snapshots; and releases http://mvn.getwoven.com/repos/woven-public-releases;), so it then stops looking in those repositories. Then, I think it finds the version 0.1.2-SNAPSHOT of 'work' in clojars, but 'work' has a dependency on 'plumbing', which maven cannot find in any repositories, so it stops. It looks like both of the dependencies you are having problems with are maintained by Woven. I would suggest first contacting them to see if they would be able to get updated artifacts into some public maven repository (be it clojars, or their own public repo). If they won't do that, then ask if they would mind if you uploaded your own versions to clojars, then use lein to upload the projects to clojars under your username, and modify your project.clj to point to your versions. Github urls: clj-time: https://github.com/getwoven/clj-time work: https://github.com/getwoven/work - Mark On Fri, May 20, 2011 at 2:08 PM, dudaroo duda...@gmail.com wrote: Thanks Mark... It seems that it is still not resolving correctly though... I changed the line in the project.clj file from: [work 0.2.4-SNAPSHOT] to [work 0.1.2-SNAPSHOT] Intuitively, I would've expected to have increased the version number as opposed to changing it to a lower number. However, this is indeed the version posted at the URL's you've provided below. Here is the current project.clj file. The only change I've made is the version of the work snapshot noted above. $ more project.clj (defproject recruitassist 1.0.0-SNAPSHOT :description FIXME: write :dependencies [[org.clojure/clojure 1.2.0] [org.clojure/clojure-contrib 1.2.0] [postgresql/postgresql 9.0-801.jdbc4] [clojureql 1.0.0] [compojure 0.5.3] [ring/ring-jetty-adapter 0.3.1] [org.clojars.gukjoon/ojdbc 1.4] [joda-time 1.6] [clj-time 0.3.0-SNAPSHOT] [work 0.1.2-SNAPSHOT] [clojure-csv 1.2.4]] :dev-dependencies [[swank-clojure 1.2.1]] :source-path src/main/clojure :test-path test/main/clojure :java-source-path src/main/java :java-test-path test/main/java :aot [recruitassist.core] :repositories {snapshots http://mvn.getwoven.com/repos/woven- public-snapshots releases http://mvn.getwoven.com/repos/woven- public-releases}) Running lein.sh deps, however continues to produce errors in resolving the dependencies... $ lein.sh deps [INFO] snapshot clj-time:clj-time:0.3.0-SNAPSHOT: checking for updates from releases [WARNING] repository metadata for: 'snapshot clj-time:clj-time:0.3.0- SNAPSHOT' could not be retrieved from repository: releases due to an error: Error transferring file [INFO] Repository 'releases' will be blacklisted [INFO] snapshot clj-time:clj-time:0.3.0-SNAPSHOT: checking for updates from snapshots [WARNING] repository metadata for: 'snapshot clj-time:clj-time:0.3.0- SNAPSHOT' could not be retrieved from repository: snapshots due to an error: Error transferring file [INFO] Repository 'snapshots' will be blacklisted Downloading: clj-sys/plumbing/0.1.2-SNAPSHOT/plumbing-0.1.2- SNAPSHOT.pom from clojure-snapshots Downloading: clj-sys/plumbing/0.1.2-SNAPSHOT/plumbing-0.1.2- SNAPSHOT.pom from clojars Downloading: clj-sys/plumbing/0.1.2-SNAPSHOT/plumbing-0.1.2- SNAPSHOT.pom from central Downloading: clj-sys/plumbing/0.1.2-SNAPSHOT/plumbing-0.1.2- SNAPSHOT.jar from clojure-snapshots Downloading: clj-sys/plumbing/0.1.2-SNAPSHOT/plumbing-0.1.2- SNAPSHOT.jar from clojars Downloading: clj-sys/plumbing/0.1.2-SNAPSHOT/plumbing-0.1.2- SNAPSHOT.jar from central An error has occurred while processing the Maven artifact tasks. Diagnosis: Unable to resolve artifact: Missing: -- 1) clj-sys:plumbing:jar:0.1.2-SNAPSHOT Try downloading the file manually from the project website. Then, install it using the command: mvn install:install-file -DgroupId=clj-sys -DartifactId=plumbing -Dversion=0.1.2-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file Alternatively, if you host your own repository you can deploy the file there: mvn deploy:deploy-file -DgroupId=clj-sys -DartifactId=plumbing - Dversion=0.1.2-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file - Durl=[url] -DrepositoryId=[id] Path to dependency: 1) org.apache.maven:super-pom:jar:2.0 2) work:work:jar:0.1.2-SNAPSHOT 3) clj-sys:plumbing:jar:0.1.2-SNAPSHOT -- 1 required artifact is missing. for artifact: org.apache.maven:super-pom:jar:2.0 from the specified remote repositories: clojure (http://build.clojure.org/releases), releases (http://mvn.getwoven.com/repos/woven-public-releases), clojars (http://clojars.org/repo/),
Re: Clojure stack
On May 20, 2011, at 5:08 PM, Michael Wood wrote: So maybe the problem you're having is that jEdit can't find the clojure.xml mode file? Not sure, but it does say I'm in Clojure mode... I'm using Mac OS X, BTW... It sounds from your other descriptions of your own experience like this failed the simple download/install test as well as my (idiosyncratic, I guess) minimal features test... ( btw for me constant 2 space indent is not the language-aware indentation/reindentation that I'm looking for.) This is the first time I've ever tried jEdit, so if the above doesn't help, sorry, I can help you :) Thanks for trying and contributing in any event! -Lee -- You 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
RIncater
Hi, Is RIncanter still alive? Cheers, U -- You 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 stack
On 20 May 2011 23:07, Lee Spector lspec...@hampshire.edu wrote: [...] BTW from what I can tell JEdit doesn't even do reasonable automatic indentation as you enter code in the first place. If I type (defn foo and hit return the cursor ends up under the second o in foo, and that seems pretty weird. If I type (conj '(a b c) and hit return it lines up under the a which is even odder -- some would say it should end up under the single quote (that'd be my vote in this situation), while some would put it under the o or the n, but I don't see any rationale for it being under the a. Well, that seems to be a constant 8 space indentation. If I were to guess I'd say jEdit is not detecting your files as Clojure files and is indenting them incorrectly as a result. -- 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 stack
On 20 May 2011 23:25, Lee Spector lspec...@hampshire.edu wrote: On May 20, 2011, at 5:08 PM, Michael Wood wrote: So maybe the problem you're having is that jEdit can't find the clojure.xml mode file? Not sure, but it does say I'm in Clojure mode... I'm using Mac OS X, BTW... It sounds from your other descriptions of your own experience like this failed the simple download/install test Well, that might be a bit unfair, because I'm using an old, no longer supported version of Ubuntu and just installed the version of jEdit in the repositories for that version of Ubuntu. I assume that downloading jEdit from the home page or using a later version of Ubuntu would allow me to install the Clojure plugins. as well as my (idiosyncratic, I guess) minimal features test... ( btw for me constant 2 space indent is not the language-aware indentation/reindentation that I'm looking for.) Yes, I agree that a constant two space indent is not ideal, which is why I mentioned it. This is the first time I've ever tried jEdit, so if the above doesn't help, sorry, I can help you :) eh... that was supposed to say sorry, I can't help you, but I think you got the idea anyway. Thanks for trying and contributing in any event! No problem. -- 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.3 Alpha 7
On Fri, May 20, 2011 at 2:24 PM, László Török ltoro...@gmail.com wrote: On May 20, 2011 7:55 PM, Fogus mefo...@gmail.com wrote: In the alpha7 release the defrecord macro was changed to generate a couple of auxiliary functions (for a record R) named map-R and -R. The first takes a map and returns a function of its contents. The second takes the same number of arguments as the record constructor. It's the definition of this second function that is reporting an error. It's easy enough to fix, but I guess the question is should it be fixed? That is, do people define records with 19+ fields? Does this pose a problem for existing code? Hi, What's the incremental runtime cost of increasing the max number of fields to 40? :-) Oh, there's no need for that. Just add a little smarts to the constructor generating macro to detect 19+ fields and then define it as (defn -Foo [ fields] (if (not= (count fields) whatever) (throw-arity-exception) (Foo. (nth fields 0) (nth fields 1) (nth fields 2) ...))) or maybe for efficiency use a let cascade: (let [p1 (first fields) fields (rest fields) p2 (first fields) fields (rest fields) ...] ...) Of course there's probably some JVM limit on the number of constructor args, too. I'd suggest if you have records that large to consider restructuring them to have a smaller number of fields that are more composite -- seqs, vectors, sets, maps, even nested records. Surely there's *some* structure beyond a heterogeneous assortment of twenty-plus objects? -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- You 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: Radically simplified Emacs and SLIME setup
On May 19, 11:15 pm, Tassilo Horn tass...@member.fsf.org wrote: Do I get you right that the output is the problem that prevents me to get to the SLIME REPL, since you didn't say anything at all about that IllegalArgumentException? I'm not sure what's going on with the IllegalArgumentException. Do you have more than one version of swank in ~/.lein/plugins? If so it's due to a separate bug in Leiningen. But I've fixed the output bug in clojure-mode 1.9.1; see if that helps. -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
Bug? (:refer-clojure ... :as) does not work.
= (ns foo (:refer-clojure :exclude [reset!] :as c)) nil = (def bar (atom [])) #'foo/bar = (reset! bar [42]) #CompilerException java.lang.Exception: Unable to resolve symbol: reset! in this context (NO_SOURCE_FILE:1) = (c/reset! bar [42]) #CompilerException java.lang.Exception: No such namespace: c (NO_SOURCE_FILE:1) = (clojure.core/reset! bar [42]) [42] Contrast with: = (ns bar (:use [clojure.set :exclude [difference] :as s])) nil = (def baz #{1 2 3}) #'bar/baz = (difference baz #{1 4 5}) #CompilerException java.lang.Exception: Unable to resolve symbol: difference in this context (NO_SOURCE_FILE:1) = (s/difference baz #{1 4 5}) #{2 3} IMO, either :as in :refer-clojure should work or it should throw this: #CompilerException java.lang.Exception: Unsupported option(s) supplied: :as (NO_SOURCE_FILE:1) Preferably the former. -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- You 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: Bug? (:refer-clojure ... :as) does not work.
Refer is not use. If you expand the use of set, it boils down to (require '[clojure.set :as s]) (refer '[clojure.set :exclude '[difference]]). If you do the same expansion for clojure.core, it works fine: (ns sample (:refer-clojure :exclude [reset!]) (:require [clojure.core :as c])) sample= c/reset! Likewise, if you only refer to clojure.set instead of use'ing it, the :as clause doesn't apply. On May 20, 4:22 pm, Ken Wesson kwess...@gmail.com wrote: = (ns foo (:refer-clojure :exclude [reset!] :as c)) nil = (def bar (atom [])) #'foo/bar = (reset! bar [42]) #CompilerException java.lang.Exception: Unable to resolve symbol: reset! in this context (NO_SOURCE_FILE:1) = (c/reset! bar [42]) #CompilerException java.lang.Exception: No such namespace: c (NO_SOURCE_FILE:1) = (clojure.core/reset! bar [42]) [42] Contrast with: = (ns bar (:use [clojure.set :exclude [difference] :as s])) nil = (def baz #{1 2 3}) #'bar/baz = (difference baz #{1 4 5}) #CompilerException java.lang.Exception: Unable to resolve symbol: difference in this context (NO_SOURCE_FILE:1) = (s/difference baz #{1 4 5}) #{2 3} IMO, either :as in :refer-clojure should work or it should throw this: #CompilerException java.lang.Exception: Unsupported option(s) supplied: :as (NO_SOURCE_FILE:1) Preferably the former. -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- You 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.contrib.priority-map issue
I've been using priority-map from clojure-contrib: https://github.com/clojure/clojure-contrib/blob/master/modules/priority-map/src/main/clojure/clojure/contrib/priority_map.clj Peek and pop don't work as I expected after doing a dissoc for an object not contained in the map. I'm pretty new to Clojure and this community - is there somewhere I should log the issue? user= (def test-map (priority-map 1 1 2 2)) #'user/test-map user= (peek (dissoc (priority-map 1 1 2 2) 1)) ; works how I expected [2 2] user= (peek (dissoc (priority-map 1 1 2 2) 3)) ; expected [1 1] [nil nil] user= (pop (dissoc (priority-map 1 1 2 2) 3)) ; expected {2 2} {1 1, 2 2} -- You 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: Bug? (:refer-clojure ... :as) does not work.
On Fri, May 20, 2011 at 7:32 PM, Alan Malloy a...@malloys.org wrote: Refer is not use. If you expand the use of set, it boils down to (require '[clojure.set :as s]) (refer '[clojure.set :exclude '[difference]]). 1. Refer should still say :as is unsupported if it's unsupported. 2. Refer-clojure is more like use than refer, because clojure.core is in effect required, simply because it's ALWAYS required. 3. Being able to :as c the core would be useful under exactly these kinds of circumstances, where you want to shadow a core function but have the original available with a conveniently short syntax. Likewise, if you only refer to clojure.set instead of use'ing it, the :as clause doesn't apply. In which case it should throw an exception. -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- You 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
Suggested doc improvements: await
Current doc string: Blocks the current thread (indefinitely!) until all actions dispatched thus far, from this thread or agent, to the agent(s) have occurred. Will block on failed agents. Will never return if a failed agent is restarted with :clear-actions true. What it doesn't note is that (as is typical, mind you, of blocking methods in Java) you can kick the thread out of its funk with interrupt: ; Make an agent = (def a (agent 1)) #'user/a ; Make agent busy and cause it to fail after five seconds = (send a #(do (Thread/sleep 5000) (/ % 0))) #Agent@53d34c: 1 ; Make a thread that will await the agent = (def t (Thread. #(try (await a) (catch InterruptedException _ (println boo!) #'user/t ; Start it = (.start t) nil ; Interrupt it (wait a few seconds before issuing this) = (.interrupt t) boo! nil So, await can be interrupted and will then throw InterruptedException, which can be caught and handled. This provides a possible means of recovery from the will never return... condition described in the docs. -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- You 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
Agent error handlers that throw exceptions themselves
The docs don't say anything about what happens if an agent error handler itself throws an exception, but the answer seems to be: absolutely nothing. = (def a (agent 1)) #'bar/a = (set-error-handler! a (fn [_ err] (if (instance? ArithmeticException err) (throw (IllegalArgumentException.)) (println err nil = (set-error-mode! a :continue) nil = (send a inc) #Agent@1a5f0f3: 2 = (send a #()) #IllegalArgumentException java.lang.IllegalArgumentException: Wrong number of args (1) passed to: bar$eval1220$fn #Agent@1a5f0f3: 2 = (send a / 0) #Agent@1a5f0f3: 2 = (send a inc) #Agent@1a5f0f3: 3 As you can see, after the / 0 send, it just quietly continues to accept messages such as inc without anything happening. If the error handler had recursed on itself with the IAE as the err this time, it would have printed #IllegalArgumentException java.lang.IllegalArgumentException. Neither did the agent enter a failed state. It looks like the IAE thrown (but not caught) inside the error handler was simply swallowed. If this is the desired behavior it should probably be documented. Recursing of course would carry the risk of an infinite loop (though I carefully constructed my test so it could not produce such a loop) and failing the agent would violate expectations for an agent set to error mode :continue, so it probably is the desired behavior. The docs also aren't explicit about what thread the error handler is called on, but the obvious implementation, namely (try (apply next-queued-action @this args) (catch Throwable t (error-handler this t))) (with a :fail agent having a handler that sets the agent's state to failed and stores the throwable), would make it the agent thread, and this experiment seems to bear out that guess: = (set-error-handler! a (fn [_ _] (println (Thread/currentThread nil = (send a / 0) #Thread Thread[pool-1-thread-1,5,main] #Agent@1a5f0f3: 3 On the other hand: = (def b (agent 1)) #'bar/b = (set-error-handler! b (fn [_ _] (println (Thread/currentThread nil = (send b / 0) #Thread Thread[pool-1-thread-2,5,main] #Agent@15dbaab: 1 = (send b inc) #CompilerException java.lang.RuntimeException: Agent is failed, needs restart (NO_SOURCE_FILE:0) points to something closer to (try (apply ...) (catch ... (error-handler this t) (if (= mode :fail) (fail-me this t))) as the actual implementation. I could dive into the source code now and see, but I'm out of time for now. :) -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- You 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: Suggested doc improvements: await
On Fri, May 20, 2011 at 8:36 PM, Ken Wesson kwess...@gmail.com wrote: Current doc string: Blocks the current thread (indefinitely!) until all actions dispatched thus far, from this thread or agent, to the agent(s) have occurred. Will block on failed agents. Will never return if a failed agent is restarted with :clear-actions true. What it doesn't note is that (as is typical, mind you, of blocking methods in Java) you can kick the thread out of its funk with interrupt. As I suspected, you can liberate (or at least kill) a thread deadlocked on a promise with Thread.interrupt() as well. The deref call will throw InterruptedException. I have also posted code for a promise whose deref will time out in some earlier thread. -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- You 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
lein usage
Dear all i downloaded lein 1.5.2. ... it does not include clojure.contrib in project.clj when creating a new project. how to do it? Where is detailed documentation for lein? How to know latest version of vairous libs to include in include in lein project.clj Thanks in advace regards Vincent -- You 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
Obfuscating error message with obscure Var corner case
= (with-local-vars [x 9] (alter-var-root x (fn [_] 3))) #CompilerException java.lang.IllegalStateException: Var null/null is unbound. (NO_SOURCE_FILE:0) Not the world's clearest error message. I'd prefer something like: #CompilerException UnsupportedOperationException: Local vars have no root binding to alter. (NO_SOURCE_FILE:0) -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- You 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.contrib.priority-map issue
Fixed. Thanks for the bug report. -- You 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
for not returning a lazy sequence
I'm working on problem 66 at project euler and this is my solution so far. It calculates the minimum xs just fine but takes almost a minute when I turn limit up to 20. It's not going to solve the problem fast enough but what I find strange it that if I set the limit to 20 then nothing happens for a while and then the minimum xs are quickly spit out. Basically, it seems like the sequence in the loop isn't lazy and I don't understand why. Algorithm: For each D iterate over the squares. The minimum x will be the first square for which decrementing it and dividing by D is another square. (time (let [limit 10 sqrt (fn [n] (if (zero? n) 0 (loop [guess (- n (/ (- (* n n) n) (* 2 n))) last-guess n] (if ( (- last-guess guess) 1/10) (let [dec-guess (long guess) inc-guess (inc dec-guess)] (condp = n (* dec-guess dec-guess) dec-guess (* inc-guess inc-guess) inc-guess guess)) (recur (- guess (/ (- (* guess guess) n) (* 2 guess))) guess)] (loop [x (for [D (range (inc limit)) :when (not (integer? (sqrt D)))] (sqrt (first (filter (comp integer? #(sqrt (/ (dec %) D))) (map #(* % %) (range 2 Double/POSITIVE_INFINITY))] (when (first x) (println (first x)) (recur (rest x)) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com 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
We need a better way to handle errors.
= (try (doall (map (partial / 36) [4 9 3 2 0])) (catch ArithmeticException _ boo!)) #CompilerException java.lang.RuntimeException: java.lang.ArithmeticException: Divide by zero (NO_SOURCE_FILE:0) The problem with trying to catch exceptions thrown from inside lazy sequence generators is that they all get wrapped in RuntimeException. Catching that works: = (try (doall (map (partial / 36) [4 9 3 2 0])) (catch RuntimeException _ boo!)) boo! but doesn't allow catch-dispatch on exception type. You can get the final cause of an exception with this: (defn get-cause [t] (loop [t t] (if-let [c (.getCause t)] (recur c) t))) You could make a catch-last macro. (defmacro catch-last [ catches] `(catch Throwable t# (let [cause# (get-cause t#)] (try (throw cause#) ~@catches seems like it should work, and macroexpands properly, but fails oddly: = (try (doall (map (partial / 36) [4 9 3 2 0])) (catch-last ArithmeticException _ boo!)) #CompilerException java.lang.Exception: Unable to resolve symbol: catch in this context (NO_SOURCE_FILE:1) If you ask me, that's a compiler bug right there; it should expand to (try (doall ...) (catch (let ...))) which is legal Clojure and a legal try-catch form in particular. This, instead, works: (defmacro try-2 [ body] (let [[try-part catches] (split-with #(not= (first %) 'catch) body) [catches finally] (split-with #(not= (first %) 'finally) catches)] `(try ~@try-part (catch Throwable t# (let [cause# (get-cause t#)] (try (throw cause#) ~@catches))) ~@finally))) = (try-2 (doall (map (partial / 36) [4 9 3 2 0])) (catch ArithmeticException _ boo!)) boo! However, if you call a Java API that wraps exceptions, you might want to catch the Java layer exception and not its own cause. That is, you could have Exception in thread Thread-1989 java.lang.RuntimeException: blah blah at stack trace here Caused by com.foo.FooFrameworkLoadResourceException: blah blah at stack trace here Caused by org.xml.sax.SAXException: blah blah at stack trace here and you probably don't care that the framework encountered some malformed XML on the web, but that it failed to load a resource. Ordinary try will catch the RuntimeExcepion and try-2 will catch the SAXException; neither will catch the FooFrameworkLoadResourceException. The simplest thing Clojure could do to alleviate this type of difficulty is to not wrap in generic RuntimeExceptions. Instead, derive ClojureRuntimeException from it and use that, and we can redefine get-cause as follows: (defn get-cause [t] (loop [t t] (if (instance? ClojureRuntimeException t) (recur (.getCause t)) t))) and then try-2 will behave as desired for cases like this. But then there's so much more that could be done, such as allowing error handlers to be called as soon as various conditions arise that can perform restarts. The options would generally be to a) propagate the exception, b) retry, c) throw an Error, and d) return some other value as the value of the expression whose evaluation aborted. So if we set up to propagate, the behavior would be the same as now. On the other hand if we set up to restart, we might use a handler like: (syntax speculative) (handler ArithmeticException _ Double/NaN) in case we'd rather have NaNs propagate through failed math, for example, or (handler IOException _ nil) if we want some I/O read operation to return nil on failure. How about (handler OutOfMemoryError _ (reset! cache {}) (retry)) with the proviso that retry reruns the failed expression as if retry were a zero-argument function containing it as its body and any unhandled exceptions thrown out of a handler are propagated. This allows propagation either via (handler FooException e (throw e)) or by not having a handler registered for FooException. Multiple retries would require try...catch inside the handler. The default in REPL sessions could even be to pop up a message box via Swing and prompt the user what to do, not unlike the errors one gets developing in typical Common Lisp environments: ! Error x _ # FooException in foo-function (x) Propagate the exception ( ) Retry ( ) Throw Error ( ) Evaluate to this value: [nil] (Copy stack trace to clipboard) (OK) where the field for the third option is of course passed through read-string or maybe even eval and throw Error would be omitted if the exception was already an Error. The proposed handler syntax deliberately looks like existing catch clauses. The hairy details include how one would set handlers -- updating a thread-local map of exception types to handler closures? The default for any given exception class would be propagate, of course. Another hairy detail would be how to resolve conflicts -- also, when to invoke handlers. Given the need for a handler to capture the failed
Re: for not returning a lazy sequence
I just remembered that people always ask me what version of clojure I'm using, 1.3.0-master-SNAPSHOT. On May 20, 9:41 pm, Jarl Haggerty jarlhagge...@gmail.com wrote: I'm working on problem 66 at project euler and this is my solution so far. It calculates the minimum xs just fine but takes almost a minute when I turn limit up to 20. It's not going to solve the problem fast enough but what I find strange it that if I set the limit to 20 then nothing happens for a while and then the minimum xs are quickly spit out. Basically, it seems like the sequence in the loop isn't lazy and I don't understand why. Algorithm: For each D iterate over the squares. The minimum x will be the first square for which decrementing it and dividing by D is another square. (time (let [limit 10 sqrt (fn [n] (if (zero? n) 0 (loop [guess (- n (/ (- (* n n) n) (* 2 n))) last-guess n] (if ( (- last-guess guess) 1/10) (let [dec-guess (long guess) inc-guess (inc dec-guess)] (condp = n (* dec-guess dec-guess) dec-guess (* inc-guess inc-guess) inc-guess guess)) (recur (- guess (/ (- (* guess guess) n) (* 2 guess))) guess)] (loop [x (for [D (range (inc limit)) :when (not (integer? (sqrt D)))] (sqrt (first (filter (comp integer? #(sqrt (/ (dec %) D))) (map #(* % %) (range 2 Double/POSITIVE_INFINITY))] (when (first x) (println (first x)) (recur (rest x)) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com 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