Re: bounded memoize
Hi Eugen, On Sat, Mar 13, 2010 at 3:28 AM, Eugen Dück wrote: > I guess I must be missing something obvious, but can't we just put > more than one thing into an atom in order to get atomic behavior? > My variations on memoize use a single atom: your bounded-memoize id roughly equivalent to my memoize2 + fifo-strategy, see http://gist.github.com/330644#LID19. Using, say, a vector. Using the simple bounded memoizer as an example, > this looks to me like it works: > > (defn bounded-memoize > [f capacity] > (let [mem (atom [{} []])] >(fn [& args] > (if-let [e (find (first @mem) args)] > (val e) >(let [ret (apply f args)] > (swap! mem #(let [cache (assoc (first %) args ret) >v (conj (second %) args)] >(if (> (count v) capacity) > [(dissoc cache (first v)) (subvec v 1)] > [cache v]))) > ret) > Two quick notes: * a PersistentQueue is a better fit there (conj at one end, pop/peek at the other) than a vector, * by padding it to the desired length (capacity) with dummy items, you are sure that the queue (or the vector) is always full, so you always have to remove an item: no more need for the (> (count v) capacity) test. > And if this works, it should be applicable to the strategy-ed > memoizers, too. > You implementation suffers from the same problems that my memoize2 (and they become worst in memoize3) which are caused by using the atom twice (once when reading, once when swapping). Say you have: (def g (bounded-memoize identity 3)) (g 0) (g 1) (g 2) so at this point the value in mem is [{(0) 0, (1) 1, (2) 2} [0 1 2]]. Now, concurrently, two threads call (g 3), each one see that 3 isn't memoized yet and swap! the new entry in. After the first swap! mem holds [{(1) 1, (2) 2 (3) 3} [1 2 3]], which is expected. However after the second swap! mem holds [{(2) 2 (3) 3} [2 3 3]]. That's why Meikel tests twice if the value is already in the cache (the first time outside of a transactio, the second time inside) and why I introduce hit-or-assoc in memoize4/memoize5. Have a nice week-end! Christophe -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
proposal for core arithmatic functions
Hi, I've been evaluating clojure with a bias around performance (I do a lot of numerical work). I don't need to the metal, but want to see that fundamental operations are comparable to java in performance and that performance can be had not at the expense of conciseness. In particular, I've noted that arithmetic such as: (+ a b c d) is not equivalent to: (+ (+ (+ a b) c) d) in performance, because the former form applies + on a list or array form (I forget which).This is regardless of whether all of the above values have primitive type hints. At least this is what I observe in debugging (correct me if I am wrong). Could + and other operators be changed to a macro mapping rather than the current defn, mapping the argument list to a binary expression tree (+ (+ (+ ... instead of the list style application (I'm guessing yes, not being familiar with CL-style macros). Secondly, if one has code like: (let [ x (int a) y (int b)] (+ (* x 2) (* y 3) (* x y 5)) (* x 2) -> a function of (int, Object), as the literal 2 is not assumed to be a primitive type.This instead needs to be mapped to: (let [ x (int a) y (int b)] (+ (+ (* x (int 2)) (* y (int 3)) (* (* x y) (int 5 I don't know if type hints can be interrogated or known at the time of macro evaluation (I'm guessing not), but if so, would like to see that in such a macro. Automatically decorating literals that are used in the context of arithmetic with a primitive would make clojure a lot more usable for performance-concerned arithmetic. I think I saw mention that #^int (and other primitive types) will be supported at some point in argument declarations as well? Thanks Jonathan -- You 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: bounded memoize
Laurent, Meikel, Christophe, I guess I must be missing something obvious, but can't we just put more than one thing into an atom in order to get atomic behavior? Using, say, a vector. Using the simple bounded memoizer as an example, this looks to me like it works: (defn bounded-memoize [f capacity] (let [mem (atom [{} []])] (fn [& args] (if-let [e (find (first @mem) args)] (val e) (let [ret (apply f args)] (swap! mem #(let [cache (assoc (first %) args ret) v (conj (second %) args)] (if (> (count v) capacity) [(dissoc cache (first v)) (subvec v 1)] [cache v]))) ret) And if this works, it should be applicable to the strategy-ed memoizers, too. Eugen On Mar 13, 4:27 am, Christophe Grand wrote: > Hi Meikel, > > Since Laurent dragged me into the discussion: > > > > On Thu, Mar 11, 2010 at 8:42 AM, Meikel Brandmeyer wrote: > > Hello Laurent, > > > On Mar 10, 11:45 am, Laurent PETIT wrote: > > > > * usage of refs : I had a bad feeling, and cgrand confirmed this to > > > me by pointing an even more interesting counter-argument. Me: using > > > refs is not mandatory since you do not need to synchronize this change > > > with anything else. > > > I don't think, that this is entirely true! You have to syncronise the > > cache with the state in the strategy. This can be done with atoms only > > if the cache and the strategy state are contained in the same atom and > > all updates happen in a single call to swap! (or reset!). As soon as > > you > > have multiple calls, you need transactions again, because the atom > > might > > change between the two calls. And you can't swap! and return a result > > at > > the same time. > > > Say you have the LRU strategy. You deref the cache, find the result > > cached. Now you swap! in the new access time into your state. But > > between the deref and the swap! another call might trigger the removal > > of the entry. So you always have to guard against the atom suddenly > > changing underneath - even if it's only one atom. > > I agree. > > > Something what annoys me more is that the computation may be fired of > > several times. Since the f is supposedly expensive, I'd rather avoid > > that. > > See my memoize5: the call isn't computed inside the swap!s > > > > > I gave it another run and came up with another solution. Even more > > hairy. :P > > > * a warm cache is fast > > * a cache miss is potentially slow, but the missing value is computed > > only > > once, multiple requests for the same item wait for the initially > > triggered > > computation > > * the cache can be updated (almost) in parallel for different items > > > (defn memoize > > ([f] (memoize f naive-strategy)) > > ([f [cache-lookup cache-update]] > > (let [cache-state (atom {})] > > (fn [& args] > > (if-let [e (cache-lookup cache-state args)] > > @(val e) > > @(locking cache-state > > (if-let [e (cache-lookup cache-state args)] > > (val e) > > (let [result (promise)] > > (.start (Thread. #(deliver result (apply f args > > (swap! cache-state assoc-in [:cache args] result) > > (cache-update cache-state args) > > result > > > But with this you can't reliably implement strategies like LRU and the > > like. > > Since you use a lock I think some clever combination of memoized functions > can create a deadlock. > > > But this is really an interesting problem. I'll mull a little more > > about it. :) > > I agree, it's interesting and here is my entry:http://gist.github.com/330644 > > Christophe -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: German Clojure Book
Stu, On 12 Mrz., 17:16, Stuart Halloway wrote: > Stefan, > > That's great news about the book, and kudos on tying it back to > funding. thank you. I sincerely hope this will really matter. And I am very happy that the publishers immediately agreed on this. Actually I only pointed them to the article in the group and they came up with the 0,50EUR per book, themselves. > I hope that everyone who finds commercial success with Clojure will > make a small, sustainable funding commitment to help Clojure thrive. While I don't think that "everyone" will be possible, I really find it a very *pleasing* thought that my work on what I currently do, will help this great programming project/language. If this may serve as a good example, even better! Nobody *has* to do this, the license allows commercial use, and I don't think that this community will frown upon small businesses making money of Clojure by using it as a tool or a topic. But we may make it a success this way. Kind regards, Stefan PS: Hopefully I can some close to the quality, you've done already... -- You 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: binary representation + operators
Yes, yes - that's what I mean. Things get a little muddled on Friday afternoon. The reader converts the representation, and there's not a fast/easy way to get the original representation back and manipulate it. On Mar 12, 2010, at 4:53 PM, Kevin Downey wrote: uh, you are confusing representation of the thing with the thing. Integers don't have bases, bases are used when displaying them. The reader does not convert a "2r0" to a "base-10 Integer value" because there is no such thing. On Fri, Mar 12, 2010 at 4:23 PM, Brendan Ribera wrote: Whenever you use the "2r0" format, the reader automatically converts it to its base-10 Integer value. This transformation happens at the reader level right now -- check out the 'matchNumber' method in LispReader.java for details. So (as far as I can tell) this means that there is no standalone binary representation for you to use; that is, there's no direct way back from an Integer value to the value that you entered in your program. You *could* do something with Integer/toBinaryString... but then you're slinging around strings to represent bits, and that just feels dirty. Are you sure you need to use bit representations instead of ints? Can you not make do with the built in clojure bit-* functions and a bit- concat like the one below? (defn bits-in "Calculates the minimum number of bits that a given Integer occupies." [n] (inc (int (/ (Math/log n) (Math/log 2) (defn bit-concat "Concatenates a collection of Integers at the bit level." [& coll] (letfn [(concat-fn [a b] (bit-or (bit-shift-left a (bits-in b)) b))] (reduce concat-fn coll))) -Brendan On Fri, Mar 12, 2010 at 2:26 PM, Scott wrote: Two questions How do I write a function 'bit' that converts an integer to binary representation: (bit 0) -> 2r0 (bit 1) -> 2r1 (bit 2) -> 2r10 (bit 3) -> 2r11 . . . As well, as function 'bit-concat' with the following behavior: (bit-concat 2r1 2r00) -> 2r100 (bit-concat 2r0 2r00) -> 2r000 (bit-concat 2r011 2r1100) -> 2r000 . . . I looked into formats, but everything defaults to integer representation. I need to stay in binary representation. Its for a genetic algorithm with grey coding. Thanks! Scott -- You 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 -- And what is good, Phaedrus, And what is not good— Need we ask anyone to tell us these things? -- You 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: Spurious STDERR output ("Picked up JAVA_TOOL_OPTIONS")
that is output by the jvm and clojure has no control over it. On Fri, Mar 12, 2010 at 4:04 PM, Michael Gardner wrote: > I noticed that when I set JAVA_TOOL_OPTIONS, clojure outputs the following to > STDERR before it runs my code: > > Picked up JAVA_TOOL_OPTIONS: ... > > This interferes with e.g. running clojure scripts as cron jobs, since it's > common to rely on the presence of output on STDERR to signal errors. > > Obviously one can work around this with IO redirection plus grep or tail, but > that's ugly and a pain. Is there a way to turn off this output entirely, or > at least to get clojure to put it on STDOUT instead? > > -Michael > > -- > You 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 -- And what is good, Phaedrus, And what is not good— Need we ask anyone to tell us these things? -- You 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: binary representation + operators
uh, you are confusing representation of the thing with the thing. Integers don't have bases, bases are used when displaying them. The reader does not convert a "2r0" to a "base-10 Integer value" because there is no such thing. On Fri, Mar 12, 2010 at 4:23 PM, Brendan Ribera wrote: > Whenever you use the "2r0" format, the reader automatically converts it to > its base-10 Integer value. This transformation happens at the reader level > right now -- check out the 'matchNumber' method in LispReader.java for > details. So (as far as I can tell) this means that there is no standalone > binary representation for you to use; that is, there's no direct way back > from an Integer value to the value that you entered in your program. You > *could* do something with Integer/toBinaryString... but then you're slinging > around strings to represent bits, and that just feels dirty. > Are you sure you need to use bit representations instead of ints? Can you > not make do with the built in clojure bit-* functions and a bit-concat like > the one below? > (defn bits-in > "Calculates the minimum number of bits that a given Integer occupies." > [n] > (inc (int (/ (Math/log n) (Math/log 2) > (defn bit-concat > "Concatenates a collection of Integers at the bit level." > [& coll] > (letfn [(concat-fn > [a b] > (bit-or > (bit-shift-left a (bits-in b)) b))] > (reduce concat-fn coll))) > -Brendan > On Fri, Mar 12, 2010 at 2:26 PM, Scott wrote: >> >> Two questions >> >> How do I write a function 'bit' that converts an integer to binary >> representation: >> >> (bit 0) -> 2r0 >> (bit 1) -> 2r1 >> (bit 2) -> 2r10 >> (bit 3) -> 2r11 >> . >> . >> . >> >> As well, as function 'bit-concat' with the following behavior: >> >> (bit-concat 2r1 2r00) -> 2r100 >> (bit-concat 2r0 2r00) -> 2r000 >> (bit-concat 2r011 2r1100) -> 2r000 >> . >> . >> . >> >> I looked into formats, but everything defaults to integer >> representation. I need to stay in binary representation. Its for a >> genetic algorithm with grey coding. >> >> Thanks! >> >> Scott >> >> -- >> You 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 -- And what is good, Phaedrus, And what is not good— Need we ask anyone to tell us these things? -- You 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: binary representation + operators
Whenever you use the "2r0" format, the reader automatically converts it to its base-10 Integer value. This transformation happens at the reader level right now -- check out the 'matchNumber' method in LispReader.java for details. So (as far as I can tell) this means that there is no standalone binary representation for you to use; that is, there's no direct way back from an Integer value to the value that you entered in your program. You *could* do something with Integer/toBinaryString... but then you're slinging around strings to represent bits, and that just feels dirty. Are you sure you need to use bit representations instead of ints? Can you not make do with the built in clojure bit-* functions and a bit-concat like the one below? (defn bits-in "Calculates the minimum number of bits that a given Integer occupies." [n] (inc (int (/ (Math/log n) (Math/log 2) (defn bit-concat "Concatenates a collection of Integers at the bit level." [& coll] (letfn [(concat-fn [a b] (bit-or (bit-shift-left a (bits-in b)) b))] (reduce concat-fn coll))) -Brendan On Fri, Mar 12, 2010 at 2:26 PM, Scott wrote: > Two questions > > How do I write a function 'bit' that converts an integer to binary > representation: > > (bit 0) -> 2r0 > (bit 1) -> 2r1 > (bit 2) -> 2r10 > (bit 3) -> 2r11 > . > . > . > > As well, as function 'bit-concat' with the following behavior: > > (bit-concat 2r1 2r00) -> 2r100 > (bit-concat 2r0 2r00) -> 2r000 > (bit-concat 2r011 2r1100) -> 2r000 > . > . > . > > I looked into formats, but everything defaults to integer > representation. I need to stay in binary representation. Its for a > genetic algorithm with grey coding. > > Thanks! > > Scott > > -- > You 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
Spurious STDERR output ("Picked up JAVA_TOOL_OPTIONS")
I noticed that when I set JAVA_TOOL_OPTIONS, clojure outputs the following to STDERR before it runs my code: Picked up JAVA_TOOL_OPTIONS: ... This interferes with e.g. running clojure scripts as cron jobs, since it's common to rely on the presence of output on STDERR to signal errors. Obviously one can work around this with IO redirection plus grep or tail, but that's ugly and a pain. Is there a way to turn off this output entirely, or at least to get clojure to put it on STDOUT instead? -Michael -- You 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
binary representation + operators
Two questions How do I write a function 'bit' that converts an integer to binary representation: (bit 0) -> 2r0 (bit 1) -> 2r1 (bit 2) -> 2r10 (bit 3) -> 2r11 . . . As well, as function 'bit-concat' with the following behavior: (bit-concat 2r1 2r00) -> 2r100 (bit-concat 2r0 2r00) -> 2r000 (bit-concat 2r011 2r1100) -> 2r000 . . . I looked into formats, but everything defaults to integer representation. I need to stay in binary representation. Its for a genetic algorithm with grey coding. Thanks! Scott -- You 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: using counterclockwise with 1.2 snapshots?
2010/3/12 Stuart Halloway : > The problem is that I don't get those choices when I am editing the existing > clojure and contrib jars added by ccw. In that scenario they seem to be > treated as external jars. Oh, then just remove the entries and create new ones of the right type. BTW, I think you just pointed a bug in ccw :) -- You 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: Visual Studio plugin
Hi Eric, I downloaded Netbeans and the Enclojure plug-in for it. It is pretty cool, though I still have to play with it more. BTW, you forgot to mention if you need this plug-in for VS 2008 or 2010? VS 2010 has a completely different model for building plug-ins than VS 2008. Also, do you think it is a one person effort? I would love to work on such stuff but haven't done anything similar before. A few days back, I was thinking that such a plug-in should be there for Sharp Develop (just because Sharp Develop is free and various Express Editions of Visual Studio don't support plug-ins). Regards, Manoj. On Mar 10, 8:57 am, Eric Thorsen wrote: > It does it matter to me how it gets written (C# or ClojureCLR) > The desire is to have a plugin that supports syntax highlighting, > completion, debugging, etc. but what I really am looking for is > something that can manage repl(s) that can load the libraries for a > given solution or set of projects (similar to what the Enclojure > plugin does in Netbeans). > Roadmap: > 1. Have a REPL window running within VS that has history (preferably > persistant across restarts), and can see a set of selected libs. > The libs could come from the solution or some other way of setting up > a context for REPLs. > 2. Have the plugin know about Clojure files. > Syntax highlighting, completion, folding, etc. > 3. Debugger support > > Eric > On Mar 9, 1:47 pm, mmwaikar wrote: > > > Forgot to ask the below mentioned questions earlier - > > > Which version of Visual Studio are you targeting - 2008 or 2010? > > Do you have a development road-map for your plug-in features? > > > Thanks, > > Manoj. > > > On Mar 9, 1:05 pm, mmwaikar wrote: > > > > Is it possible to write a plug-in in Clojure CLR? And if it is, would > > > you prefer it in Clojure CLR or C# is fine? Also do you want both REPL > > > and syntax highlighting for clj files in Visual Studio? > > > > Thanks, > > > Manoj. > > > > On Mar 8, 2:17 pm, Eric Thorsen wrote: > > > > > Is there/is anyone working on/is anyone interested in working on a > > > > Visual Studio plugin for a Clojure REPL for clojureCLR? > > > > > My company might be interested in sponsoring this work. > > > > > Thanks! > > > > eric -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Something similar to (match) from scheme?
http://www.brool.com/index.php/pattern-matching-in-clojure On Mar 11, 2:02 pm, Luka wrote: > Is there a way to do pattern matching on values in clojure similar to > this: > > http://docs.plt-scheme.org/reference/match.html > > What I'm trying to do is simple lexing/parsing: I would match parts > of strings with regexp, and then do a parsing with match form. What is > the best way of doing this in clojure? -- You 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: Leiningen, Clojure and libraries: what am I missing?
I'm confused. Why do we need symlinks or copies at all? Why can't we just tell clojure where it's supposed to find a given projects dependencies? I'm sure the answer involves some mumbo-jumbo about classpath and what not, but surely there has to be a better alternative than whatever maven/leiningen are currently doing. Not if we want to precompile code and create an überjar, or otherwise integrate with Java. Ultimately, tools expect a pile of jars listed in the classpath. Management of those jars is easier if they're (actually or virtually) in one place. I'm from a CL background too, and I do long for the days of the continuum from a load script through to ASDF and friends, but at some point it makes sense to give up and do things The Java Way. Even simple things like log4j.properties are looked up on… you guessed it: the classpath. It's not a battle that's worth fighting. On a related note, why is the build system the cool kids seem to be using (leiningen) controlled by a bunch of shell scripts? Surely things like compiling .clj source files and making jars should be operations one can drive from the clojure repl, no? It's a shell script wrapping a bunch of Clojure code. I'm sure you could use Leiningen as a library: each task is simply a function which calls out to Maven or Lancet. Oh, and on a related note, I hate being forced into the src, test, lib heirarchy... Let me put my files where I want them to go. Whatever happened to the lancet build system from Stuart Holloway's book? That seemed to make sense to me. That's convention over configuration (though you can put alternatives in the Leiningen project.clj file). It's one of those things where it's easier to go with the flow, I'm afraid. -- You 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: Uber-newbie question: (+ '(1 2 3))
On 12 March 2010 20:02, Michał Marczyk wrote: > (apply + '(1 2 3)) > > cf. (doc apply) Also: (reduce + '(1 2 3)) Or: (reduce + [1 2 3]) which is perhaps more idiomatic. -- Michael Wood -- You 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: Rebinding vars at compile time
there are a number of vars that are bound in clojure.main's repl, *assert* is one of them. So in the repl you can use set!. On Thu, Mar 11, 2010 at 3:25 PM, Benjamin Teuber wrote: >> > (def *assert* false) >> >> You cannot use def to change the value of a var in another namespace. >> This is nothing specific to *assert* or to clojure.core. > >> Here is what you can do instead: >> >> (alter-var-root (var *assert*) (fn [_] false)) > > I actually tried from inside clojure.core, and actually alter-var-root > doesn't do the job either - maybe because there's already a thread- > local binding there which shadows the root? > >> However, what you probably want is >> >> (set! *assert* false) > > Great, indeed :) > > And thanks for your warning about macroexpand-all. > > Benjamin > > -- > You 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 -- And what is good, Phaedrus, And what is not good— Need we ask anyone to tell us these things? -- You 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: using counterclockwise with 1.2 snapshots?
The problem is that I don't get those choices when I am editing the existing clojure and contrib jars added by ccw. In that scenario they seem to be treated as external jars. Stu Hi, 2010/3/12 Stuart Halloway : When I update the classpath to point to Clojure 1.2 jars in Eclipse, the .classpath file has full paths, which doesn't seem very friendly to scms or teams. Is there a setting somewhere that makes Eclipse do the right thing? There are several ways of adding dependencies to a java (and so clojure/ccw) project in Eclipse. I guess you chose the most "platform-specific" one. Try others :-) "Add jars" : will reference the jar relative to the "concept" of project as known by Eclipse => very portable, but your jar must be visible from Eclipse (generally in a sub folder of your project) "Add external jars" : you can reference by absolute path a jar which can be anywhere in your filesystem (only relevant if you have the same fs layout between dev environments) "Add Variable" : you can define a point of indirection named variable. The variable will be configured once per Eclipse instance (per dev environment), and so you can share things more easily. Interesting when the jar will not be in the Eclipse project, more portable than "Add external jars" etc. If you used "Add jars", you should not have a full fs path. HTH, -- Laurent And out of curiosity: under what circumstances would saving full paths for dependencies stored within a project *ever* be a reasonable default? Ask the Eclipse guys :) -- You 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: bounded memoize
Hi Meikel, Since Laurent dragged me into the discussion: On Thu, Mar 11, 2010 at 8:42 AM, Meikel Brandmeyer wrote: > Hello Laurent, > > On Mar 10, 11:45 am, Laurent PETIT wrote: > > > * usage of refs : I had a bad feeling, and cgrand confirmed this to > > me by pointing an even more interesting counter-argument. Me: using > > refs is not mandatory since you do not need to synchronize this change > > with anything else. > > I don't think, that this is entirely true! You have to syncronise the > cache with the state in the strategy. This can be done with atoms only > if the cache and the strategy state are contained in the same atom and > all updates happen in a single call to swap! (or reset!). As soon as > you > have multiple calls, you need transactions again, because the atom > might > change between the two calls. And you can't swap! and return a result > at > the same time. > > Say you have the LRU strategy. You deref the cache, find the result > cached. Now you swap! in the new access time into your state. But > between the deref and the swap! another call might trigger the removal > of the entry. So you always have to guard against the atom suddenly > changing underneath - even if it's only one atom. > I agree. > Something what annoys me more is that the computation may be fired of > several times. Since the f is supposedly expensive, I'd rather avoid > that. > See my memoize5: the call isn't computed inside the swap!s > I gave it another run and came up with another solution. Even more > hairy. :P > > * a warm cache is fast > * a cache miss is potentially slow, but the missing value is computed > only > once, multiple requests for the same item wait for the initially > triggered > computation > * the cache can be updated (almost) in parallel for different items > > (defn memoize > ([f] (memoize f naive-strategy)) > ([f [cache-lookup cache-update]] >(let [cache-state (atom {})] > (fn [& args] > (if-let [e (cache-lookup cache-state args)] > @(val e) > @(locking cache-state >(if-let [e (cache-lookup cache-state args)] > (val e) > (let [result (promise)] >(.start (Thread. #(deliver result (apply f args >(swap! cache-state assoc-in [:cache args] result) >(cache-update cache-state args) >result > > But with this you can't reliably implement strategies like LRU and the > like. > Since you use a lock I think some clever combination of memoized functions can create a deadlock. > But this is really an interesting problem. I'll mull a little more > about it. :) > I agree, it's interesting and here is my entry: http://gist.github.com/330644 Christophe -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Leiningen, Clojure and libraries: what am I missing?
Oh, and on a related note, I hate being forced into the src, test, lib heirarchy... Let me put my files where I want them to go. Whatever happened to the lancet build system from Stuart Holloway's book? That seemed to make sense to me. I think there is a big benefit in consistent directory structure across projects, but agree that it should still be *possible* to configure things a different way. I am not actively developing Lancet. Anyone who wants is certainly welcome to fork it and continue. It is used under the covers in Leiningen IIRC. Stu -- You 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: Why clojure does not have remove-duplicates and delete-duplicates ?
Thanks, I was sure that there was an easier way. I updated the Rosetta Code's entry using 'distinct'. Giacecco On Mar 12, 6:28 pm, Mark Engelberg wrote: > You could also use the "distinct" function, if you really need a lazy > sequence. > > 2010/3/12 Mark Engelberg > > > Why not just use the "set" function? > > > On Fri, Mar 12, 2010 at 10:20 AM, Giacecco wrote: > > >> All, > >> Why does clojure miss lisps' remove-duplicates and delete-duplicates? -- You 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: Leiningen, Clojure and libraries: what am I missing?
I'm confused. Why do we need symlinks or copies at all? Why can't we just tell clojure where it's supposed to find a given projects dependencies? I'm sure the answer involves some mumbo-jumbo about classpath and what not, but surely there has to be a better alternative than whatever maven/leiningen are currently doing. Granted, I'm coming at this from a common lisp background, but I think many lisp developers are used to not just working on a single project, but working on a bunch of related projects simultaneously, including the the language/runtime environment itself. I'd like a single instance of clojure, a single clojure-contrib (I still don't understand why I had to (admittedly seamlessly) download a bunch of jars to clean the build directory), a single incanter instance, etc... Perhaps I'm missing the obvious here, but I continue to fail to understand why the clojure world is doing things this way. On a related note, why is the build system the cool kids seem to be using (leiningen) controlled by a bunch of shell scripts? Surely things like compiling .clj source files and making jars should be operations one can drive from the clojure repl, no? Oh, and on a related note, I hate being forced into the src, test, lib heirarchy... Let me put my files where I want them to go. Whatever happened to the lancet build system from Stuart Holloway's book? That seemed to make sense to me. thanks, Cyrus On Mar 11, 2010, at 1:32 PM, Phil Hagelberg wrote: > On Wed, Mar 10, 2010 at 10:24 PM, Meikel Brandmeyer wrote: > On Mar > 11, 5:07 am, Brent Millare wrote: > >>> Since leiningen downloads everything to a local repo, can't we do away >>> with copies and use symlinks if they are supported by the filesystem? >>> I feel there should be an option for this. >> >> Why not adding the files from the repo directly to the classpath? >> Works everywhere and doesn't copy... > > Historically this has been because calculating the classpath couldn't > be done in Clojure itself since it needed to be done before the JVM > booted. Having to figure this kind of thing out in a shell script or > in elisp is a headache if the rules are not simple. But now with the > subclassloader approach that lein and mvn use it's less of an issue. > But it would mean deprecating the pure-elisp swank launcher, and I > don't know how it would affect other tools (IDEs, etc), so I'm still > hesitant. > > I would be happy with a (simple-ish) patch to enable optionally > switching to using symlinks or hard-links as this would be the > lowest-impact fix, but I can't bring myself to care enough about the > number of megabytes currently being wasted to code it myself; sorry. > > -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 -- You 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: Why clojure does not have remove-duplicates and delete-duplicates ?
You could also use the "distinct" function, if you really need a lazy sequence. 2010/3/12 Mark Engelberg > Why not just use the "set" function? > > On Fri, Mar 12, 2010 at 10:20 AM, Giacecco wrote: > >> All, >> Why does clojure miss lisps' remove-duplicates and delete-duplicates? >> >> -- You 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: Why clojure does not have remove-duplicates and delete-duplicates ?
There's also "distinct": http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/distinct On Fri, Mar 12, 2010 at 10:24 AM, Mark Engelberg wrote: > Why not just use the "set" function? > > > On Fri, Mar 12, 2010 at 10:20 AM, Giacecco wrote: > >> All, >> Why does clojure miss lisps' remove-duplicates and delete-duplicates? >> >> -- > You 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: Why clojure does not have remove-duplicates and delete-duplicates ?
Why not just use the "set" function? On Fri, Mar 12, 2010 at 10:20 AM, Giacecco wrote: > All, > Why does clojure miss lisps' remove-duplicates and delete-duplicates? > > -- You 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
Why clojure does not have remove-duplicates and delete-duplicates ?
All, Why does clojure miss lisps' remove-duplicates and delete-duplicates? I understand that delete-duplicates is destructive, so Rich cannot approve it. But what about remove-duplicates, that is not? The solution I found at http://bit.ly/byCyx2 is ridicously complex, isn't it? G. -- You 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: Uber-newbie question: (+ '(1 2 3))
(apply + '(1 2 3)) cf. (doc apply) Sincerely, Michał -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Uber-newbie question: (+ '(1 2 3))
Sorry to use the forum for this, and feel free to insult me, but I've been searching for the solution to this for a couple of hours.I also have Stuart Halloway's "Programming Clojure" but the book is not very useful as a reference for this kind of problems, unless you remember by heart every example you've met. I know that I can sum any list of numbers doing (+ 1 2 3 ...) But what if my sequence of numbers is already in a list? The statement below does not work of course... (+ '(1 2 3) ) and the REPL returns an error that means nothing... user=> (+ '(1 2 3)) java.lang.ClassCastException (NO_SOURCE_FILE:0) I am sure that the solution must be very easy, like a reader macro of some kind. Please help, thanks! G. -- You 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: using counterclockwise with 1.2 snapshots?
Hi, 2010/3/12 Stuart Halloway : > When I update the classpath to point to Clojure 1.2 jars in Eclipse, the > .classpath file has full paths, which doesn't seem very friendly to scms or > teams. Is there a setting somewhere that makes Eclipse do the right thing? There are several ways of adding dependencies to a java (and so clojure/ccw) project in Eclipse. I guess you chose the most "platform-specific" one. Try others :-) "Add jars" : will reference the jar relative to the "concept" of project as known by Eclipse => very portable, but your jar must be visible from Eclipse (generally in a sub folder of your project) "Add external jars" : you can reference by absolute path a jar which can be anywhere in your filesystem (only relevant if you have the same fs layout between dev environments) "Add Variable" : you can define a point of indirection named variable. The variable will be configured once per Eclipse instance (per dev environment), and so you can share things more easily. Interesting when the jar will not be in the Eclipse project, more portable than "Add external jars" etc. If you used "Add jars", you should not have a full fs path. HTH, -- Laurent > And out of curiosity: under what circumstances would saving full paths for > dependencies stored within a project *ever* be a reasonable default? Ask the Eclipse guys :) -- You 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: using counterclockwise with 1.2 snapshots?
When I update the classpath to point to Clojure 1.2 jars in Eclipse, the .classpath file has full paths, which doesn't seem very friendly to scms or teams. Is there a setting somewhere that makes Eclipse do the right thing? And out of curiosity: under what circumstances would saving full paths for dependencies stored within a project *ever* be a reasonable default? Stu -- You 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: using counterclockwise with 1.2 snapshots?
Laurent, Yes, thanks! I am a little slow today. Splitting time between Clojure and taxes. :-) Stu Hi, did the following help ? 2010/3/11 Laurent PETIT : Hi Stuart, 2010/3/11 Stuart Halloway : What is the preferred way of using counterclockwise with 1.2 snapshots. Here is how I retrofitted an existing project: (1) Create a Clojure project on top of the exiting source dir Yes. (2) Under "Run Configurations" add user entries for lib/**.jar, ahead of the 1.1 bits installed by the project wizard This seems to work, but if there is a preferred way I would love to know about it. This one I think could be done in a more "eclipse-ish way": since a clojure project in ccw is really just a java project with some extras, you just go to the project's properties > Java build path > Libraries , you select in turn clojure.jar and clojure-contrib.jar entries, click on edit, and replace by the good ones in your lib/ directory. This will be stored by eclipse in the regular .classpath JDT configuration file, can be shared among devs via the scm, so that everytime one creates a launch configuration for the project, everythin is already configured. HTH, -- 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 -- You 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: jogl classpath not found
Yes, it was a silly typo. Needed to move -cp over. Thanks for the help everyone. Whole command for reference: java -Djava.library.path=./jogl-2.0-linux-amd64/lib -cp ~/clojure/ clojure-1.0.0.jar:./jogl-2.0-linux-amd64/lib/jogl.all.jar:./jogl-2.0- linux-amd64/lib/gluegen-rt.jar:./jogl-2.0-linux-amd64/lib/ nativewindow.all.jar clojure.main test.lsp On Mar 12, 8:20 am, Michał Marczyk wrote: > On 12 March 2010 17:09, strattonbrazil wrote: > > > java -cp -Djava.library.path=./jogl-2.0-linux-amd64/lib ~/clojure/ > > clojure-1.0.0.jar:./jogl-2.0-linux-amd64/lib/jogl.all.jar:./jogl-2.0- > > linux-amd64/lib/gluegen-rt.jar:./jogl-2.0-linux-amd64/lib/ > > nativewindow.all.jar clojure.main test.clj > > Note that you've got a space, rather than a colon or " -cp ", between > -Djava.library.path=./jogl-2.0-linux-amd64/lib and the rest of the > jars. Perhaps that's what causes the problem? > > Sincerely, > Michał -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: jogl classpath not found
On 12 March 2010 17:09, strattonbrazil wrote: > java -cp -Djava.library.path=./jogl-2.0-linux-amd64/lib ~/clojure/ > clojure-1.0.0.jar:./jogl-2.0-linux-amd64/lib/jogl.all.jar:./jogl-2.0- > linux-amd64/lib/gluegen-rt.jar:./jogl-2.0-linux-amd64/lib/ > nativewindow.all.jar clojure.main test.clj Note that you've got a space, rather than a colon or " -cp ", between -Djava.library.path=./jogl-2.0-linux-amd64/lib and the rest of the jars. Perhaps that's what causes the problem? Sincerely, Michał -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: using counterclockwise with 1.2 snapshots?
Hi, did the following help ? 2010/3/11 Laurent PETIT : > Hi Stuart, > > 2010/3/11 Stuart Halloway : >> What is the preferred way of using counterclockwise with 1.2 snapshots. Here >> is how I retrofitted an existing project: >> >> (1) Create a Clojure project on top of the exiting source dir > > Yes. > >> (2) Under "Run Configurations" add user entries for lib/**.jar, ahead of the >> 1.1 bits installed by the project wizard >> >> This seems to work, but if there is a preferred way I would love to know >> about it. > > This one I think could be done in a more "eclipse-ish way": since a > clojure project in ccw is really just a java project with some extras, > you just go to the project's properties > Java build path > Libraries > , you select in turn clojure.jar and clojure-contrib.jar entries, > click on edit, and replace by the good ones in your lib/ directory. > > This will be stored by eclipse in the regular .classpath JDT > configuration file, can be shared among devs via the scm, so that > everytime one creates a launch configuration for the project, > everythin is already configured. > > HTH, > > -- > 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: [ANN] German Clojure Book
Stefan, That's great news about the book, and kudos on tying it back to funding. Clojure is open source *and* funded by its community--a terrific combination. We did something similar for Programming Clojure. The royalties belong to Relevance, as I wrote the book on day- job time, and thus Relevance is pleased to be funding Clojure at a substantial level. See http://clojure.org/funders for a list of all the organizations and individuals who have contributed. The sheer number of contributors is impressive, and a testimony to the community evolving around Clojure. I hope that everyone who finds commercial success with Clojure will make a small, sustainable funding commitment to help Clojure thrive. Stu Fellow Clojurians, please let me announce the writing of another book on Clojure, this time in German. So, if you're familiar with that language you might want to read the tiny webpage at http://www.clojure-buch.de where I'll announce whatever little news I may have, or the publisher's page at http://www.dpunkt.de/buecher/3372.html. With regards to funding Clojure (http://clojure.org/funding) I'm rather happy to announce that for each copy sold 0.50EUR will go to Rich Hickey. I really hope that this will help funding Clojure 2011. Kind regards, Stefan Kamphausen -- You 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: jogl classpath not found
I've also tried setting the library path on the command line already like this java -cp -Djava.library.path=./jogl-2.0-linux-amd64/lib ~/clojure/ clojure-1.0.0.jar:./jogl-2.0-linux-amd64/lib/jogl.all.jar:./jogl-2.0- linux-amd64/lib/gluegen-rt.jar:./jogl-2.0-linux-amd64/lib/ nativewindow.all.jar clojure.main test.clj But that just causes another error. Exception in thread "Main Thread" java.lang.NoClassDefFoundError: /usr/ home/jstratton/clojure/clojure-1/0/0/jar://jogl-2/0-linux-amd64/lib/ jogl/all/jar://jogl-2/0-linux-amd64/lib/gluegen-rt/jar://jogl-2/0- linux-amd64/lib/nativewindow/all/jar I don't know if adding to the library path is causing the new error, or if this is just the next error in getting the script to run. Am I setting the library path incorrectly? On Mar 11, 5:01 pm, strattonbrazil wrote: > Hrmm, that's weird. Well thanks for that. I just put it all on the > command line for now. Does -jar ignore -cp or something because that > didn't work for me? > > This is what I got now... > > java -cp ~/clojure/clojure-1.0.0.jar:./jogl-2.0-linux-amd64/lib/ > jogl.all.jar:./jogl-2.0-linux-amd64/lib/gluegen-rt.jar:./jogl-2.0- > linux-amd64/lib/nativewindow.all.jar clojure.main test.clj > > I'm past the import errors, so that should be resolved in the future, > but I'm not at the linking error. Following the user guide, it says I > can just set LD_LIBRARY_PATH to the directory containing the .so's, > but that's not working either. Can that be set on the command line > calling java as well? > > Thanks. > > On Mar 11, 4:05 pm, Zach Tellman wrote: > > > In the past, I haven't had a lot of luck putting the JOGL libraries on > > the classpath. A much better approach, I've found, is to create a > > custom script to load up clojure, and put the class and library paths > > as parameters to the java executable. My library used to target JOGL > > (it now uses LWJGL), and the script I suggested in the wiki can be > > found athttp://wiki.github.com/ztellman/penumbra/getting-started/16. > > Hopefully some variation on that should work for you. > > > On Mar 11, 1:28 pm, strattonbrazil wrote: > > > > I downloaded the new jogl 2.0 libs and can't get jogl to be recognized > > > in my classpath. It's stuck on the import. > > > > (import '(javax.media.opengl.awt GLCanvas)) > > > > In my shell I have clojure aliased to 'java -jar clojure-1.0.0.jar' > > > > I have my CLASSPATH as > > > > echo $CLASSPATH > > > ./jogl-2.0-linux-amd64/lib/jogl.all.jar:./jogl-2.0-linux-amd64/lib/ > > > nativewindow.all.jar:./jogl-2.0-linux-amd64/lib/gluegen-rt.jar > > > > I found this command online to print the classpath in clojure, which I > > > assume works. > > > (println (seq (.getURLs (java.lang.ClassLoader/ > > > getSystemClassLoader > > > > But I only get the clojure jar. > > > > (#) > > > > This is the actual error message from the import: > > > > Exception in thread "Main Thread" java.lang.ClassNotFoundException: > > > javax.media.opengl.awt.GLCanvas (test.clj:0) > > > at clojure.lang.Compiler.eval(Compiler.java:4543) > > > at clojure.lang.Compiler.load(Compiler.java:4857) > > > at clojure.lang.Compiler.loadFile(Compiler.java:4824) > > > at clojure.main$load_script__5833.invoke(main.clj:206) > > > at clojure.main$script_opt__5864.invoke(main.clj:258) > > > at clojure.main$main__5888.doInvoke(main.clj:333) > > > at clojure.lang.RestFn.invoke(RestFn.java:413) > > > at clojure.lang.Var.invoke(Var.java:346) > > > at clojure.lang.AFn.applyToHelper(AFn.java:173) > > > at clojure.lang.Var.applyTo(Var.java:463) > > > at clojure.main.main(main.java:39) > > > Caused by: java.lang.ClassNotFoundException: > > > javax.media.opengl.awt.GLCanvas > > > at java.lang.Class.forName0(Native Method) > > > at java.lang.Class.forName(Class.java:247) > > > at clojure.lang.RT.classForName(RT.java:1487) > > > at clojure.core$import__4028.doInvoke(core.clj:1860) > > > at clojure.lang.RestFn.invoke(RestFn.java:426) > > > at user$eval__4.invoke(test.clj:3) > > > at clojure.lang.Compiler.eval(Compiler.java:4532) > > > ... 10 more -- You 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: quote versus backquote
On 12.03.2010, at 10:32, Felix Breuer wrote: > I guess I have to rephrase my previous questions to make them more > clear: Why was this particular behavior chosen? What is the benefit of > having quote and syntax-quote behaving differently in this regard? Quote and syntax-quote serve very different purposes, despite the similar name an a superficial resemblance in functionality. Quote is for writing unevaluated literals. You just want nothing changed in its argument, which is exactly what it does. Syntax-quote is used for writing code templates, mostly inside macro definitions. In that situation, you want symbols be resolved in namespaces, just as they would if the form being constructed were used literally in the same place. To make code templates work correctly across namespaces (typically a macro is expanded in another namespace than the one it was defined in), it is thus preferable to have symbols converted to their namespace-qualified counterparts. You might want to look at this blog post, whose topic is an exceptional situation where syntax-quote is not the most convenient way to write code templates: http://onclojure.com/2010/02/23/generating-deftype-forms-in-macros/ > Suppose I wanted to write my own version of = called (myeql a b) such > that > > user> (myeql '(v 1) `(v 1)) > true > > I would have to walk the expression tree in both expressions and > replace all unqualified symbols with the respective qualified symbols. > How would I go about this? Is there an idomatic way to achieve this? I don't see why you would ever want to do this, but here is one approach (not idiomatic): - use clojure.walk to apply a transformation all over a form - for each leaf of the tree, check if it is a symbol and if so, convert it to its namespace-qualified equivalent. What is rather strange in my opinion is the fact that there is no utility function in clojure. core that does the second step, i.e. there is no function that will map 'x to `x. However, it is not difficult to write such a function: (defn qualified-symbol [s] (symbol (str *ns*) (str s))) Konrad. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: "Interesting" integer behavior
On Mar 10, 3:53 pm, Brian Hurt wrote: > In a recent clojure: > > user=> (class 2147483647) > java.lang.Integer > user=> (class (inc 2147483647)) > java.math.BigInteger > user=> (class (inc (inc 2147483647))) > java.lang.Long > user=> > > This isn't *technically* a bug, but it is an odd behavior. > Odd no longer - thanks for the report! Rich -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: quote versus backquote
On 12 Mrz., 01:58, Richard Newman wrote: > > Is there a good reason for this behavior? What is the rationale behind > > it? > > Read this. > > http://clojure.org/reader#syntax-quote Thank you for pointing me to this reference. As far as I understand it, the difference between a quoted expression and a syntax-quoted expression is that in the syntax-quated expression, all symbols will be qualified, whereas in the quoted expression they will not be. I guess I have to rephrase my previous questions to make them more clear: Why was this particular behavior chosen? What is the benefit of having quote and syntax-quote behaving differently in this regard? Suppose I wanted to write my own version of = called (myeql a b) such that user> (myeql '(v 1) `(v 1)) true I would have to walk the expression tree in both expressions and replace all unqualified symbols with the respective qualified symbols. How would I go about this? Is there an idomatic way to achieve this? Thank you, Felix -- You 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: German Clojure Book
Hi, On Mar 12, 11:11 am, Michael Kohl wrote: > Congratulations! If you ever need any German language proof-reading > let me know, heh, thanks for the offer. I think I did things in the wrong order: I first recruited a team of friendly proof readers and then made the public announcement later. However, feel free to contact me via email. > I worked as a freelance IT journalist for German and > Austrian publications for 4 years. :-) OK, I only have three years for the German Linux Magazin up my sleeve. You win :-) Cheers, Stefan -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: [ANN] German Clojure Book
Congratulations! If you ever need any German language proof-reading let me know, I worked as a freelance IT journalist for German and Austrian publications for 4 years. :-) On Thu, Mar 11, 2010 at 10:39 PM, Stefan Kamphausen wrote: > Fellow Clojurians, > > please let me announce the writing of another book on Clojure, this > time in German. > > So, if you're familiar with that language you might want to read the > tiny webpage at http://www.clojure-buch.de where I'll announce > whatever little news I may have, or the publisher's page at > http://www.dpunkt.de/buecher/3372.html. > > With regards to funding Clojure (http://clojure.org/funding) I'm > rather happy to announce that for each copy sold 0.50EUR will go to > Rich Hickey. I really hope that this will help funding Clojure 2011. > > Kind regards, > Stefan Kamphausen > > -- > You 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