Please submit patches as attachments to issues
Hello all, I've been reading the list in chunks during the holidays, often without enough time to do triage. Given the volume, it's important that all patches be submitted (by registered contributors only) as attachments to issues in the issues system: http://code.google.com/p/clojure/issues/list That way they won't get lost in the message traffic. I'll be sorting through them over the next few days, with an emphasis on fixes over features, in an effort to get 1.0 out. Patches to outstanding defects (many are trivial) most welcome. Thanks to all for your contributions and support - here's to a productive 2009! 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 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: reduction
Chouser a écrit : >> What do you think of adding rec-cons, rec-cat and your (fixed) cute >> version instead to seq-utils? >> (see http://clj-me.blogspot.com/2009/01/recursive-seqs.html for rec-cat >> and rec-cons) >> > > That'd be fine too, especially for rec-cons and rec-cat. The > 'reduction' in your blog makes a nice example, but I assume it runs > slower than your version above. > I never liked my iterate-based function: it is overly complicated (I wrote it because the intuition that iterate can be used kept nagging me) and yours (built with rec-cons) is more than twice faster! 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 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: .newInstance error
Justin Johnson wrote: > Will someone please explain to me why this isn't working? Is there > something special about newInstance that I'm missing? > > user=> (. org.tmatesoft.svn.core.wc.SVNClientManager newInstance) > # >From the Javadoc, newInstance is a static method on SVNClientManager, so you want: (org.tmatesoft.svn.core.wc.SVNClientManager/newInstance) -Drew --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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 -~--~~~~--~~--~--~---
.newInstance error
Will someone please explain to me why this isn't working? Is there something special about newInstance that I'm missing? user=> (. org.tmatesoft.svn.core.wc.SVNClientManager newInstance) # user=> (.newInstance org.tmatesoft.svn.core.wc.SVNClientManager) java.lang.InstantiationException: org.tmatesoft.svn.core.wc.SVNClientManager (NO_SOURCE_FILE:0) user=> (macroexpand-1 '(.newInstance org.tmatesoft.svn.core.wc.SVNClientManager)) (. (clojure.core/identity org.tmatesoft.svn.core.wc.SVNClientManager) newInstance) user=> (clojure.core/identity org.tmatesoft.svn.core.wc.SVNClientManager) org.tmatesoft.svn.core.wc.SVNClientManager user=> (. (clojure.core/identity org.tmatesoft.svn.core.wc.SVNClientManager) newInstance) java.lang.InstantiationException: org.tmatesoft.svn.core.wc.SVNClientManager (NO_SOURCE_FILE:0) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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 -~--~~~~--~~--~--~---
newbie question on binding
Hi, This example is from clojure site. My question is on line 5 and line 6: The confusion is str is a function and here looks like used as a regular variable. Thanks in advance. Sun (defn loves [x y] (str x " loves " y)) (defn test-rebind [] (println (loves "ricky" "lucy")) (let [str-orig str]---> line 5: (binding [str (fn [& args]--> line 6: (println "Logging str") (apply str-orig args))]-->line 8: (println (loves "fred" "ethel") (test-rebind) ricky loves lucy Logging str Logging str Logging str Logging str Logging str fred loves ethel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: Programming Style
Hi, Am 05.01.2009 um 14:02 schrieb Shmurk: That's where I failed, I didn't knew that Java method calls were expanded like macros, thank you very much for the answer! Well. All the interop with Java works via the . and new special forms. The Classname. and .methodName shortcuts are just for convenience. Sincerely Meikel smime.p7s Description: S/MIME cryptographic signature
Re: reduction
Chouser a écrit : > On Dec 12 2008, 3:35 pm, Christophe Grand > wrote: > >> I was sure it was a job for iterate: >> >> (defn reductions >> "Returns a lazy seq of the intermediate values of the reduction (as >> per reduce) of coll by f, starting with init." >> ([f coll] >>(if (seq coll) >> (for [s (iterate (fn [[x & s]] (if s >> (lazy-cons (f x (first s)) (rest s >>coll) >>:while s] >>(first s)) >> (list (f >> ([f val coll] >>(reductions f (cons val coll >> > > This isn't in clojure.core yet (any reason why not?) so would you mind > if I add it to clojure.contrib.seq-utils? Or of course you can do it > if you prefer. :-) > What do you think of adding rec-cons, rec-cat and your (fixed) cute version instead to seq-utils? (see http://clj-me.blogspot.com/2009/01/recursive-seqs.html for rec-cat and rec-cons) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: meaning and pronunciation of Clojure
Not related to or compatible with Common Lisp, so no. Pretty sure its not an acronym. Closures are a commonly used concept in functional programming, so it isn't mysterious where it came from. Just drop a J in there for Javaness. On Jan 3, 9:05 pm, Ed wrote: > I have been wanting to know the same thing...I was guessing Clojure > was an acronym for: Common_Lisp_Object_Java_?something?_?something?_? > something?, or possibly Concurrency_Language_OnThe_JVM_?something?_? > something?_?something?...I am dying to know. Or, like others have > cited, Closure en Francais 'Clojure'what does the name stand for > and mean? > > Can somebody post the history of the language, what the name means, > how it was chosen, were there any working names for the language > before it was called Clojureetc. Is the inventor a Seattle > Seahawks fan, the colors of the Clojure Icon suggest so. > > Thanks...happy hackin' --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: newbie question on binding
On Monday 05 January 2009 09:35, wubbie wrote: > Hi, > This example is from clojure site. > My question is on line 5 and line 6: > The confusion is str is a function and here looks like used as a > regular variable. > > Thanks in advance. > Sun > > > (defn loves [x y] > (str x " loves " y)) > (defn test-rebind [] > (println (loves "ricky" "lucy")) > (let [str-orig str]---> line 5: > (binding [str (fn [& args]--> line 6: > (println "Logging str") > (apply str-orig args))]-->line 8: > (println (loves "fred" "ethel") > (test-rebind) The value held by the global Var named "str" is saved in str-orig. Then inside the let that binds str-orig, a local override of that global binding is established that essentially, within the scope of that (binding ...) form, redefines str. This is a dynamically scoped binding in the classic sense that when code that invokes (str ...) is called somewhere "beneath" or "inside" this local (binding ...), it will get the logging form of (str), which, after printing its logging output, defers to the original str function via the value saved in str-orig. Other calls to (str ...) (in other threads), even if they occur concurrent to the execution of loves will not be affected by this local binding. Neat, eh? > ricky loves lucy > Logging str > Logging str > Logging str > Logging str > Logging str > fred loves ethel Randall Schulz --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: newbie question on binding
On Mon, Jan 5, 2009 at 6:35 PM, wubbie wrote: > > Hi, > This example is from clojure site. > My question is on line 5 and line 6: > The confusion is str is a function and here looks like used as a > regular variable. The var that is clojure.core/str aka. 'str, points to a function that implements it. And vars, any vars, can be shadowed/rebound temporarily, and this is what 'binding does. > > Thanks in advance. > Sun > > > (defn loves [x y] > (str x " loves " y)) > (defn test-rebind [] > (println (loves "ricky" "lucy")) > (let [str-orig str]---> line 5: >(binding [str (fn [& args]--> line 6: >(println "Logging str") >(apply str-orig args))]-->line 8: > (println (loves "fred" "ethel") > (test-rebind) > > ricky loves lucy > Logging str > Logging str > Logging str > Logging str > Logging str > fred loves ethel > > > > -- Venlig hilsen / Kind regards, Christian Vest Hansen. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: Programming Style
Hi, Am 05.01.2009 um 10:30 schrieb Shmurk: I have one questions about the "programming style" used in the Clojure standard library. For example, in the file core.clj, I see: (. *out* (flush)) This is the oldest form. Why is it written like this? Could we write it like this instead: (. *out* flush) Yes. It could be as well written like this. or the more concise: (.flush *out*) This is the newest form complementing the Classname. form for (new Classname). While these new forms are available, what would be the use of rewritten everything? The last form is translated to the second anyway. 1:1 user=> (macroexpand-1 '(.foo bar)) (. bar foo) Is it more efficient internally? Since this is basically all the same, I wouldn't expect it to have some effect on efficiency. Sincerely Meikel smime.p7s Description: S/MIME cryptographic signature
Re: .newInstance error
Ah, static methods... Clearly I haven't spent enough time in the Java world. user=> (org.tmatesoft.svn.core.wc.SVNClientManager/newInstance) # On Mon, Jan 5, 2009 at 8:41 AM, Justin Johnson wrote: > Will someone please explain to me why this isn't working? Is there > something special about newInstance that I'm missing? > > user=> (. org.tmatesoft.svn.core.wc.SVNClientManager newInstance) > # > > user=> (.newInstance org.tmatesoft.svn.core.wc.SVNClientManager) > java.lang.InstantiationException: > org.tmatesoft.svn.core.wc.SVNClientManager (NO_SOURCE_FILE:0) > > user=> (macroexpand-1 '(.newInstance > org.tmatesoft.svn.core.wc.SVNClientManager)) > (. (clojure.core/identity org.tmatesoft.svn.core.wc.SVNClientManager) > newInstance) > > user=> (clojure.core/identity org.tmatesoft.svn.core.wc.SVNClientManager) > org.tmatesoft.svn.core.wc.SVNClientManager > > user=> (. (clojure.core/identity > org.tmatesoft.svn.core.wc.SVNClientManager) newInstance) > java.lang.InstantiationException: > org.tmatesoft.svn.core.wc.SVNClientManager (NO_SOURCE_FILE:0) > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: meaning and pronunciation of Clojure
On Sat, Jan 3, 2009 at 9:10 PM, Mark Volkmann wrote: > > On Sat, Jan 3, 2009 at 7:36 PM, Randall R Schulz wrote: >> >> On Saturday 03 January 2009 17:32, Tom Faulhaber wrote: >>> Think of a French-style j like in bonjour, Jean Renoir, or Jacques >>> Cousteau. That gives the word "Clojure" a sound that's *very* similar >>> to the concept of a closure. And the "j" evokes the JVM. >> >> And that is how I pronounce the middle consonant in "closure." > > Me too, but some pronounce it just like "closure". > > Hey Rich, can you confirm what is official according to you? > > Should the "j" be pronounced like a "j" or like an "s"? > Clojure is pronounced exactly like closure, where the s/j has the zh sound as in azure, pleasure etc. > Did you pick the name based on starting with the word "closure" and > replacing the "s" with "j" for Java? It seems pretty likely, but it > would be nice to have that confirmed. > The name was chosen to be unique. I wanted to involve c (c#), l (lisp) and j (java). Once I came up with Clojure, given the pun on closure, the available domains and vast emptiness of the googlespace, it was an easy decision. 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 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: reduction
Chouser a écrit : > On Mon, Jan 5, 2009 at 9:53 AM, Christophe Grand > wrote: > >> Chouser a écrit : >> >>> This isn't in clojure.core yet (any reason why not?) so would you mind >>> if I add it to clojure.contrib.seq-utils? Or of course you can do it >>> if you prefer. :-) >> hat do you think of adding rec-cons, rec-cat and your (fixed) cute >> version instead to seq-utils? >> (see http://clj-me.blogspot.com/2009/01/recursive-seqs.html for rec-cat >> and rec-cons) >> > > That'd be fine too, especially for rec-cons and rec-cat. Stuart, Do you think rec-cat, rec-cons and reductions belong to seq-utils? 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 To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: newbie question on binding
Hi, Am 05.01.2009 um 18:35 schrieb wubbie: This example is from clojure site. My question is on line 5 and line 6: The confusion is str is a function and here looks like used as a regular variable. Thanks in advance. binding can be used to temporarily assign a different value to a global Var. Let's understand the example line by line. (defn loves [x y] (str x " loves " y)) First we define a function "loves" which uses the standard str function to concate it's arguments. So far easy to understand. (defn test-rebind [] (println (loves "ricky" "lucy")) Here we do a proof of concept and show that our function "loves" works as expected. Output: ricky loves lucy Now to nitty-gritty: (let [str-orig str]---> line 5: First we save the original str function in a local. (binding [str (fn [& args]--> line 6: (println "Logging str") (apply str-orig args))]-->line 8: Now we use binding to replace the global str function with another one, which we define using the original str function. We log, that we called our modified function and the just delegate all arguments to the original str function, which we saved in str-orig. This modified str is only available inside the body of the binding form. We leave it by reaching the end of the body or throwing an exception, the original str is again restored. Also other threads also don't see the modified str. This is really restricted to the body of the binding. Now we call again our initial function "loves". Please note: we did not modify our function in any way. (println (loves "fred" "ethel") See the output: Logging str Logging str Logging str Logging str Logging str fred loves ethel Huh? So although we did not modify our "loves" function we get a different output? Why is that. The solution is binding. The loves function is called *inside* the binding body and although it is defined *outside* the binding, it will use the modified str function. So you are right the binding looks similar to a let. (binding [str ...] ...) vs. (let [str ...] ...) However the let introduces a new "str" which *shadows* the global str function and is only visible for the code in the let. In particular functions called inside the let will see the str which was in effect when they were defined. The binding however *replaces* the str which was in effect, when the function was defined. Of course this works only with global Vars and not with locals as introduced by let. (Note: the number of "Logging"s depends on the implementation of the str function.) Hope this helps. Sincerely Meikel smime.p7s Description: S/MIME cryptographic signature
Re: Suggestion: introduce (defn name attr-map? [params*] doc-string body) form.
On Mon, Dec 29, 2008 at 1:59 PM, Christian Vest Hansen wrote: > > Rich & rest. > > I have gone through the process of implementing this in defn. The > patch is inlined for commenting (if need be) and attached for accurate > application. For the record, this proposal has been considered and rejected: http://clojure-log.n01se.net/date/2008-12-30.html#10:50 Thanks for your efforts, Christian! --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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 -~--~~~~--~~--~--~---
Programming Style
Hi, I'm new to Clojure and I love it so far. It's the first Lisp that I can use professionally and it's great. I have one questions about the "programming style" used in the Clojure standard library. For example, in the file core.clj, I see: (. *out* (flush)) Why is it written like this? Could we write it like this instead: (. *out* flush) or the more concise: (.flush *out*) Is it more efficient internally? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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 two list comprehensions are different?
On Sat, Jan 3, 2009 at 6:20 PM, Olov Lassus wrote: > >> The 'let' macro already has a similar check. >> >> Attached is a patch that adds even-ness and related assertions to a >> bunch of core macros. > > That's better - I applied the patch and it's working as expected here. Thanks. I've created an issue for this: http://code.google.com/p/clojure/issues/detail?id=31 --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: Understanding how to use namespaces
On Tue, 30 Dec 2008 22:25:35 -0800 "Mark Engelberg" wrote: > >In Clojure Box, is there any way to make the REPL automatically "use" >whatever namespaces are in the files you are actively working on? > If you are working on a namespace, you shouldn't 'use' it, you should switch the REPL to that namespace with either (in-ns 'name-of-ns) or, specifically in SLIME, with ,change-package or ,cp. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: Functional Shuffle
Hey Aria, Here's my (not functional) but reasonably fast (Knuth) shuffle I've been using. (defn random-permutation [s] "Return a random permutation of this seq." (let [arr (to-array s) len (alength arr)] (dotimes [i (dec len)] (let [r (+ i (rand-int (- len i))), prev (aget arr i)] (aset arr i (aget arr r)) (aset arr r prev))) (seq arr))) -Jason --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: Updating website and Clojure files
All the above are addressed with a patch at: http://code.google.com/p/clojure/issues/detail?id=32 --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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.sql (connection) public?
On Sun, 04 Jan 2009 13:50:44 -0500 "Stephen C. Gilardi" wrote: > > On Dec 15, 2008, at 6:48 AM, black...@ipowerhouse.com wrote: > > > This may be a problem with the way I'm doing things but I think it > > would be useful for the (connection) function of internal to not be > > internal. For example, lets say i do a query on a db to see if a > > user exists, if they don't I want to insert, so I need a new > > statement for that within the same transaction, i.e. i need to get > > hold of the connection itself to create my new statement. Right > > now, I'm doing (internal/connection) but I think it should be part > > of the public interface as it's something that happens frequently. > > connection is now (r340) part of the public API for > clojure.contrib.sql. Thanks for the feedback! > > --Steve > thanks, very useful. -- None are more hopelessly enslaved than those who falsely believe they are free — Goethe --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: Math functions
On Jan 3, 7:46 pm, vogelrn wrote: > sqrt(a/b) should always be equal to sqrt(a)/sqrt(b) since (a/b)^m = > a^m/b^m for b != 0. However, I'm unsure of whether it's the best > option for ratios because unless both the numerator and the > denominator are perfect squares, you're going to end up with a float > anyway. This is trading an extra sqrt for precision in the relatively > uncommon situation where both numbers are perfect squares. *nodsnodsnods* > As for taking square roots involving complex numbers, I've been > considering that as well, but I think it might be a bad idea to have > it as a part of the normal sqrt function. In the majority of > situations, taking the square root of a negative number is a bad thing > and probably shouldn't be allowed. An alternative sqrt associated > with complex numbers could be appropriate instead. I agree. Perhaps this article will be relevant for those interested in such a project: http://www.eecs.berkeley.edu/Pubs/TechRpts/1992/6127.html mfh --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: reduction
On Mon, Jan 5, 2009 at 9:53 AM, Christophe Grand wrote: > > Chouser a écrit : >> On Dec 12 2008, 3:35 pm, Christophe Grand >> wrote: >> >>> I was sure it was a job for iterate: >>> >>> (defn reductions >>> "Returns a lazy seq of the intermediate values of the reduction (as >>> per reduce) of coll by f, starting with init." >>> ([f coll] >>>(if (seq coll) >>> (for [s (iterate (fn [[x & s]] (if s >>> (lazy-cons (f x (first s)) (rest s >>>coll) >>>:while s] >>>(first s)) >>> (list (f >>> ([f val coll] >>>(reductions f (cons val coll >>> >> >> This isn't in clojure.core yet (any reason why not?) so would you mind >> if I add it to clojure.contrib.seq-utils? Or of course you can do it >> if you prefer. :-) >> > > What do you think of adding rec-cons, rec-cat and your (fixed) cute > version instead to seq-utils? > (see http://clj-me.blogspot.com/2009/01/recursive-seqs.html for rec-cat > and rec-cons) That'd be fine too, especially for rec-cons and rec-cat. The 'reduction' in your blog makes a nice example, but I assume it runs slower than your version above. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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 -~--~~~~--~~--~--~---
quote on side effects
I'm trying to recall where I heard a quote that goes something like this. "If none of your functions have side effects then all you're doing is heating up the processor." Of course you should avoid side effects in most of your functions, but at least one of them needs to have a side effect for most applications. Does anyone recall who said something like that? -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: Programming Style
On Jan 5, 1:00 pm, Meikel Brandmeyer wrote: > While these new forms are > available, what would be the use of rewritten everything? I'm not trying to rewrite anything, I'm just so thrilled about this new language that I was (for once in my life) looking at the source trying to study what was happening under the hood. > The last form is translated to the second anyway. > > 1:1 user=> (macroexpand-1 '(.foo bar)) > (. bar foo) That's where I failed, I didn't knew that Java method calls were expanded like macros, thank you very much for the answer! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: Serializing functions
I think the best way would be to simply store functions as lists (e.g. (fn [] ...)) in the file, use clojure.core/read to read the data structure and store both the list representation and the eval'd function object in the program. This might be implemented by having a memoizing 'call' function, take a list and arguments and call the eval'd list with the arguments, for example: ;;; File "a" contains: {:a-fun (fn [x] (+ 2 x))} user=> (def data (with-in-str (slurp "a") (read))) #'user/data user=> data {:a-fun (fn [x] (+ 2 x))} user=> (def call (memoize (fn [l & args] (apply (eval l) args #'user/call user=> (call (data :a-fun) 3) 5 ;;; Also, rationale for memoization: user=> (defmacro slow-compilation [] (Thread/sleep 1000)) nil user=> (time (call '(fn [] (slow-compilation) 1))) "Elapsed time: 1012.398507 msecs" 1 user=> (time (call '(fn [] (slow-compilation) 1))) "Elapsed time: 0.368762 msecs" 1 ;; If an additional layer of visible indirection is not adequate, I guess you can hide it by defining a java class which is constructed with a list representing the function, evals the list in the constructor, implements IFn and passes calls to it's methods to the function and prints itself readably, for example #=(TheClass. '(fn [])). Instances of the class would otherwise behave like Clojure functions. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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 -~--~~~~--~~--~--~---
yet another Clojure snake
Since there has been so much back-and-forth about the Clojure snake, I decided to write one [1]. Like Mark, my goal is to create a readable version, but the details are quite different. I plan to use this as the code example for the Swing section in the book. Feedback welcome. Stuart [1] http://github.com/stuarthalloway/programming-clojure/tree/master/examples/snake.clj --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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 -~--~~~~--~~--~--~---
java.io.IOException: Not enough storage is available to process this command
I often get this error when experimenting with clojure. I just pasted Stuart's new 'snakes' code into the repl and received this error after almost every line. I've never seen this error before, and I do Java programming all day. My Java code is multi-threaded, processes lots of data...in other words, my machines resources get exercised fairly well. I'm not sure why clojure throws this exception after defining just a namespace! According to google, this "storage" doesn't refer to disk space, rather to the heap (again, I have apps that load a gigabyte in memory, they crash in all kinds of spectacular ways but never with this exception). I have seen this on my office desktop as well as home laptop. Any ideas? Thanks ---Exception example- C:\proj\clojure>java -jar clojure.jar Clojure user=> (ns examples.snake java.io.IOException: Not enough storage is available to process this command user=> (:import (java.awt Color) (javax.swing JPanel JFrame Timer JOptionPane) java.io.IOException: Not enough storage is available to process this command user=>(java.awt.event ActionListener KeyListener)) java.io.IOException: Not enough storage is available to process this command user=> (:use clojure.contrib.import-static java.io.IOException: Not enough storage is available to process this command user=> [clojure.contrib.seq-utils :only (includes?)])) java.io.IOException: Not enough storage is available to process this command user=> (import-static java.awt.event.KeyEvent VK_LEFT VK_RIGHT VK_UP VK_DOWN) java.io.IOException: Not enough storage is available to process this command user=> java.io.IOException: Not enough storage is available to process this command user=> ; Game board and coordinates. points are [x,y] vectors java.io.IOException: Not enough storage is available to process this command user=> (def width 75) java.io.IOException: Not enough storage is available to process this command user=> (def height 50) java.io.IOException: Not enough storage is available to process this command user=> (def point-size 10) java.io.IOException: Not enough storage is available to process this command user=> (def turn-millis 75) java.io.IOException: Not enough storage is available to process this command user=> (def win-length 5) java.io.IOException: Not enough storage is available to process this command user=> --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: yet another Clojure snake
On Mon, Jan 5, 2009 at 3:54 PM, Stuart Halloway wrote: > > Since there has been so much back-and-forth about the Clojure snake, I > decided to write one [1]. Like Mark, my goal is to create a readable > version, but the details are quite different. > > I plan to use this as the code example for the Swing section in the > book. Feedback welcome. > > Stuart > > [1] > http://github.com/stuarthalloway/programming-clojure/tree/master/examples/snake.clj I can't believe I'm posting again on this topic. ...but it just struck me the snake body is a list, but is being used as a queue. Wouldn't a PersistentQueue be a better fit? --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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 on side effects
On Mon, Jan 5, 2009 at 3:48 PM, Mark Volkmann wrote: > > I'm trying to recall where I heard a quote that goes something like this. > > "If none of your functions have side effects then all you're doing is > heating up the processor." > > Of course you should avoid side effects in most of your functions, but > at least one of them needs to have a side effect for most > applications. > > Does anyone recall who said something like that? This is a little more specific, but the only thing that came to mind: Q: I wonder what (reduce + natural-numbers) should yield A: a very warm computer http://clojure-log.n01se.net/date/2008-10-18.html#10:30a --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure Box, alpha
Just downloaded clojurebox and it installs like a charm here (windows vista business). It looks like I am stuck with windows at my new workspace (just had my first day of work there), so to have clojurebox was a nice thing. One question is how I would go about to setting up a emacs --daemon and emacsclient combination in clojurebox? Being able to detach and quit the emacs client and later on connect back to it saves me from accidentally stopping a long simulation in windows because I quitted the emacs program. Currently if I try to C-x #, I get the message "No server editing buffers exist" On Nov 30 2008, 4:54 pm, Shawn wrote: > On Nov 23, 7:39 pm, "Shawn Hoover" wrote: > > > Here's a first pass at a Windows installer for a Clojure environment in > > Emacs:http://clojure.bighugh.com/clojure-box-r1109-setup.exe. > > There's a new version up with a few tweaks. The most helpful change > was a fix to allow swank to pick up all your jars under ~/.clojure and > put them on the java classpath. > > You can just get the newest fromhttp://clojure.bighugh.com. > > Shawn --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: yet another Clojure snake
Nice use of 'import-static' and multimethods for 'paint' ;-) Personally, I would move (def timer (Timer. turn-millis panel)) to the end: (doto panel (.setFocusable true) (.addKeyListener panel)) (doto frame (.add panel) (.setSize (* width point-size) (* height point-size)) (.setVisible true)) (def timer (Timer. turn-millis panel)) (.start timer) and you can also use (in my opinion maybe less readable) form: (def timer (doto (Timer. turn-millis panel) (.start))) Greetings, Frantisek On Jan 5, 9:54 pm, Stuart Halloway wrote: > Since there has been so much back-and-forth about the Clojure snake, I > decided to write one [1]. Like Mark, my goal is to create a readable > version, but the details are quite different. > > I plan to use this as the code example for the Swing section in the > book. Feedback welcome. > > Stuart > > [1]http://github.com/stuarthalloway/programming-clojure/tree/master/exam... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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 on side effects
On Mon, Jan 5, 2009 at 2:48 PM, Mark Volkmann wrote: > > I'm trying to recall where I heard a quote that goes something like this. > > "If none of your functions have side effects then all you're doing is > heating up the processor." > > Of course you should avoid side effects in most of your functions, but > at least one of them needs to have a side effect for most > applications. > > Does anyone recall who said something like that? > I remember reading something very similar, most likely on Hacker News < http://news.ycombinator.com> but I can't seem to dig it up on Google. -- Cosmin Stejerean http://offbytwo.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 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 on side effects
Closest I can get is this quote from a blog (http:// voelterblog.blogspot.com/2008_03_01_archive.html) but I remember it being written nicer somewhere else as well. However, using purely functional programming is also not very useful, since, if we allow no side effects, our program will do nothing except heat up the CPU ((c) Simon Peyton Jones, who talked about Haskell (to the Conference, and to me in an SE Radio interview, during which I think I actually understood monads). On Jan 5, 10:16 pm, Chouser wrote: > On Mon, Jan 5, 2009 at 3:48 PM, Mark Volkmann > wrote: > > > I'm trying to recall where I heard a quote that goes something like this. > > > "If none of your functions have side effects then all you're doing is > > heating up the processor." > > > Of course you should avoid side effects in most of your functions, but > > at least one of them needs to have a side effect for most > > applications. > > > Does anyone recall who said something like that? > > This is a little more specific, but the only thing that came to mind: > > Q: I wonder what (reduce + natural-numbers) should yield > A: a very warm computer > > http://clojure-log.n01se.net/date/2008-10-18.html#10:30a > > --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: yet another Clojure snake
PS: Sometimes the apple is too close to the edge or not seen at all. Might need to adjust apple position generation. On Jan 5, 10:26 pm, Fanda wrote: > Nice use of 'import-static' and multimethods for 'paint' ;-) > > Personally, I would move (def timer (Timer. turn-millis panel)) to the > end: > > (doto panel > (.setFocusable true) > (.addKeyListener panel)) > > (doto frame > (.add panel) > (.setSize (* width point-size) (* height point-size)) > (.setVisible true)) > > (def timer (Timer. turn-millis panel)) > (.start timer) > > and you can also use (in my opinion maybe less readable) form: > > (def timer > (doto (Timer. turn-millis panel) > (.start))) > > Greetings, Frantisek > > On Jan 5, 9:54 pm, Stuart Halloway wrote: > > > Since there has been so much back-and-forth about the Clojure snake, I > > decided to write one [1]. Like Mark, my goal is to create a readable > > version, but the details are quite different. > > > I plan to use this as the code example for the Swing section in the > > book. Feedback welcome. > > > Stuart > > > [1]http://github.com/stuarthalloway/programming-clojure/tree/master/exam... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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 on side effects
On Jan 5, 12:48 pm, "Mark Volkmann" wrote: > I'm trying to recall where I heard a quote that goes something like this. > > "If none of your functions have side effects then all you're doing is > heating up the processor." > > Of course you should avoid side effects in most of your functions, but > at least one of them needs to have a side effect for most > applications. Ha! Well, that's a snarky quote for this newsgroup -- of course the program should do some IO in order to be useful, but that's really the only part that requires side effects from the programmer's perspective. (Of course the hardware implements the programming model using side effects!) mfh --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: Some code review for clj-record?
On Mon, Jan 5, 2009 at 1:29 AM, Brian Doyle wrote: > ... Instead of > just returning a hash of errors what about returning the record with the > errors hash in > the metadata? That way you just have the data and the errors in one That's an interesting idea. On the one hand it seems weird to me that a function (other than (meta ...) might return a value that's equal to its input but with new metadata hanging off it. On the other hand, it's pretty convenient to have both the inputs and validation errors together. I guess it comes down to what belongs in metadata. While errors are certainly data about other data, they don't feel to me like metadata a la :doc, :tag, :file, :line, and :test. They're the sort of thing I'd show in an application's UI as part of normal user interactions, rather than something used only behind the scenes, so they feel to me like first-class data. -hume. -- http://elhumidor.blogspot.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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 -~--~~~~--~~--~--~---
per-defmulti hierarchies
Dear Clojurians, This patch allows multimethods to use different hierarchies, than the global hierarchy for use with isa?. Currently only the global hierarchy is possible. The patch extends the MultiFn class to accept also a Var pointing to a hierarchy. The rationale is, that otherwise the multimethod cannot be extended with derivation after it's definition. Hence it cannot receive the hierarchy directly. To promote that every hierarchy must be a Var, derive and underive are modified to act on vars instead of the hierarchies directly. Furthermore the convenience macros defhierarchy and defhierarchy- are provided, which define new hierarchies with optional docstring support and automatic initialisation with make-hierarchy. This is listed as a "hot" item in the Todo list and is connected to http://code.google.com/p/clojure/issues/detail?id=8. In fact the patch there is needed as a prerequisite. Example of usage: (defhierarchy our-hierarchy "This is a dedicated hierarchy for our own purposes!") ; Note: here we need the Var, hence the #'. ; Should this be handled via a macro? (derive #'our-hierarchy :xxx :yyy) (defmulti foo identity :hierarchy our-hierarchy) (defmethod foo :yyy [x] (println "We are in" :yyy "but got" x)) Comments and feedback appreciated. Sincerely Meikel issue-8a.diff Description: Binary data smime.p7s Description: S/MIME cryptographic signature
Re: newbie question on binding
Hi, Why are there multiple "Logging str" output. Also in (apply str-orig args), I don't see any args passed at all! Thanks sun On Jan 5, 2:14 pm, Meikel Brandmeyer wrote: > Hi, > > Am 05.01.2009 um 18:35 schrieb wubbie: > > > This example is from clojure site. > > My question is on line 5 and line 6: > > The confusion is str is a function and here looks like used as a > > regular variable. > > > Thanks in advance. > > binding can be used to temporarily assign > a different value to a global Var. > > Let's understand the example line by line. > > > (defn loves [x y] > > (str x " loves " y)) > > First we define a function "loves" which uses > the standard str function to concate it's > arguments. So far easy to understand. > > > (defn test-rebind [] > > (println (loves "ricky" "lucy")) > > Here we do a proof of concept and show > that our function "loves" works as expected. > > Output: > > > ricky loves lucy > > Now to nitty-gritty: > > > (let [str-orig str]---> line 5: > > First we save the original str function in > a local. > > >(binding [str (fn [& args]--> line 6: > >(println "Logging str") > >(apply str-orig args))]-->line 8: > > Now we use binding to replace the global > str function with another one, which we > define using the original str function. We > log, that we called our modified function > and the just delegate all arguments to the > original str function, which we saved in > str-orig. > > This modified str is only available inside > the body of the binding form. We leave > it by reaching the end of the body or throwing > an exception, the original str is again > restored. Also other threads also don't see > the modified str. This is really restricted > to the body of the binding. > > Now we call again our initial function "loves". > Please note: we did not modify our function > in any way. > > > (println (loves "fred" "ethel") > > See the output: > > > Logging str > > Logging str > > Logging str > > Logging str > > Logging str > > fred loves ethel > > Huh? So although we did not modify our "loves" > function we get a different output? Why is that. > The solution is binding. The loves function is > called *inside* the binding body and although > it is defined *outside* the binding, it will use the > modified str function. > > So you are right the binding looks similar to > a let. > > (binding [str ...] >...) > > vs. > > (let [str ...] >...) > > However the let introduces a new "str" which > *shadows* the global str function and is only > visible for the code in the let. In particular > functions called inside the let will see the > str which was in effect when they were defined. > > The binding however *replaces* the str which > was in effect, when the function was defined. > Of course this works only with global Vars and > not with locals as introduced by let. > > (Note: the number of "Logging"s depends on > the implementation of the str function.) > > Hope this helps. > > Sincerely > Meikel > > smime.p7s > 5KViewDownload --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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 on side effects
I thought that first place I heard it was Rich mentioning it in one of the videos on http://clojure.blip.tv, but I can't find it. On Mon, Jan 5, 2009 at 3:48 PM, Mark Volkmann wrote: > > I'm trying to recall where I heard a quote that goes something like this. > > "If none of your functions have side effects then all you're doing is > heating up the processor." > > Of course you should avoid side effects in most of your functions, but > at least one of them needs to have a side effect for most > applications. > > Does anyone recall who said something like that? > > -- > R. Mark Volkmann > Object Computing, Inc. > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: Some code review for clj-record?
> I guess it comes down to what belongs in metadata. While errors are > certainly data about other data, they don't feel to me like metadata a > la :doc, :tag, :file, :line, and :test. They're the sort of thing I'd > show in an application's UI as part of normal user interactions, > rather than something used only behind the scenes, so they feel to me > like first-class data. > I've found that reading Rich's description of what metadata is is a good way to see more clearly in cases such as these, specifically this passage I find helpful: "An important thing to understand about metadata is that it is not considered to be part of the value of an object. As such, metadata does not impact equality (or hash codes). Two objects that differ only in metadata are equal." So ask yourself, should the object with the errors hash in metadata be equal (as defined by the = function) to the object without the same error information? If yes, then metadata seems like a good fit. Of course, if its nonsensical to consider such a comparison then thinking about it this way may not make things any more clear. I'm not too involved with the code here, but one thing that seems dangerous about storing this information in metadata here is that if this is supposed to signify an error condition, then it is entirely possible for code to use the returned value and never realize there was an error if they didn't know to look at the metadata. If you return a different object altogether then the caller of the code will discover one way or another that the returned object isn't what they expected. ... just some thoughts ... /mike. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure Box, alpha
On Mon, Jan 5, 2009 at 4:24 PM, bOR_ wrote: > > Just downloaded clojurebox and it installs like a charm here (windows > vista business). It looks like I am stuck with windows at my new > workspace (just had my first day of work there), so to have clojurebox > was a nice thing. One question is how I would go about to setting up a > emacs --daemon and emacsclient combination in clojurebox? Being able > to detach and quit the emacs client and later on connect back to it > saves me from accidentally stopping a long simulation in windows > because I quitted the emacs program. > > Currently if I try to C-x #, I get the message "No server editing > buffers exist" The emacs that you start with the Clojure Box icon becomes a server, but it has no clients waiting on it. If you later run c:\Program Files\Clojure Box\emacs\emacs\bin\emacsclient.exe from the command line or as an editor for a program like subversion, the file to edit will pop up in the Clojure Box and you can use C-x #. Does that help? Shawn --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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 on side effects
On Mon, Jan 5, 2009 at 5:04 PM, Paul Barry wrote: > I thought that first place I heard it was Rich mentioning it in one of the > videos on http://clojure.blip.tv, but I can't find it. > That certainly didn't originate with me. Probably from the Haskell folks. Rich > On Mon, Jan 5, 2009 at 3:48 PM, Mark Volkmann > wrote: >> >> I'm trying to recall where I heard a quote that goes something like this. >> >> "If none of your functions have side effects then all you're doing is >> heating up the processor." >> >> Of course you should avoid side effects in most of your functions, but >> at least one of them needs to have a side effect for most >> applications. >> >> Does anyone recall who said something like that? >> >> -- >> R. Mark Volkmann >> Object Computing, Inc. >> >> > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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 on side effects
I don't know if he was the first, but I heard it from Simon Peyton Jones first: In an interview around 3:15: http://channel9.msdn.com/posts/Charles/Simon-Peyton-Jones-Towards-a-Programming-Language-Nirvana/ When answering a question around 10:40: http://oscon.blip.tv/file/324976 Kevin On Jan 5, 12:48 pm, "Mark Volkmann" wrote: > I'm trying to recall where I heard a quote that goes something like this. > > "If none of your functions have side effects then all you're doing is > heating up the processor." > > Of course you should avoid side effects in most of your functions, but > at least one of them needs to have a side effect for most > applications. > > Does anyone recall who said something like that? > > -- > R. Mark Volkmann > Object Computing, Inc. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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 on side effects
I love the quote. I believe it comes from one of the co-creators of Haskell, Simon Peyton Jones (http://en.wikipedia.org/wiki/ Simon_Peyton_Jones). Here's a short video of him with the quote around 3:15: http://channel9.msdn.com/posts/Charles/Simon-Peyton-Jones-Towards-a-Programming-Language-Nirvana/ Kevin Krouse On Jan 5, 12:48 pm, "Mark Volkmann" wrote: > I'm trying to recall where I heard a quote that goes something like this. > > "If none of your functions have side effects then all you're doing is > heating up the processor." > > Of course you should avoid side effects in most of your functions, but > at least one of them needs to have a side effect for most > applications. > > Does anyone recall who said something like that? > > -- > R. Mark Volkmann > Object Computing, Inc. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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 -~--~~~~--~~--~--~---
process inferior-lisp core dumped!
Hi, I got core dump while running It's on linux(ubuntu): user=> (if true (str "true!") (str "false!") ) "true!" user=> (if false (str "true!") (str "false!")) "false!" user=> # # An unexpected error has been detected by Java Runtime Environment: # # SIGSEGV (0xb) at pc=0x064f7e68, pid=6500, tid=2893822864 # # Java VM: Java HotSpot(TM) Server VM (11.0-b16 mixed mode linux-x86) # Problematic frame: # V [libjvm.so+0x4f7e68] # # An error report file with more information is saved as: # /home/sun/clj-src/code/hs_err_pid6500.log # # If you would like to submit a bug report, please visit: # http://java.sun.com/webapps/bugreport/crash.jsp # The crash happened outside the Java Virtual Machine in native code. # See problematic frame for where to report the bug. # Process inferior-lisp aborted (core dumped) Does it happen once in a while? If interested in the content of the log file, pls let me know. Sun --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: yet another Clojure snake
On Mon, Jan 5, 2009 at 2:54 PM, Stuart Halloway wrote: > > Since there has been so much back-and-forth about the Clojure snake, I > decided to write one [1]. Like Mark, my goal is to create a readable > version, but the details are quite different. > > I plan to use this as the code example for the Swing section in the > book. Feedback welcome. > > Stuart > > [1] > http://github.com/stuarthalloway/programming-clojure/tree/master/examples/snake.clj The #1 lesson I learned from this exercise is that the "extract method" refactoring pattern is your friend. I think it made a world of difference in making the code more readable. I see you didn't override getPreferredSize in your JPanel proxy and instead call setSize on the JFrame. When I did that I found that the size included the JFrame title bar. That meant that the usable area wasn't as tall as what I wanted. That's why I decided to size the panel instead and then pack the frame. I'm curious why you decided not to surround the names of constants with asterisks. I see you did use asterisks around snake and apple. I'm still confused about whether there's a convention for that. Why did you decide not to use structmaps for the snake and the apple? -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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 on side effects
I didn't think you originated the quote, but did you mention it during one of your presentations? Maybe I'm thinking of someone else. On Mon, Jan 5, 2009 at 6:09 PM, Rich Hickey wrote: > > On Mon, Jan 5, 2009 at 5:04 PM, Paul Barry wrote: > > I thought that first place I heard it was Rich mentioning it in one of > the > > videos on http://clojure.blip.tv, but I can't find it. > > > > That certainly didn't originate with me. Probably from the Haskell folks. > > Rich > > > On Mon, Jan 5, 2009 at 3:48 PM, Mark Volkmann > > > wrote: > >> > >> I'm trying to recall where I heard a quote that goes something like > this. > >> > >> "If none of your functions have side effects then all you're doing is > >> heating up the processor." > >> > >> Of course you should avoid side effects in most of your functions, but > >> at least one of them needs to have a side effect for most > >> applications. > >> > >> Does anyone recall who said something like that? > >> > >> -- > >> R. Mark Volkmann > >> Object Computing, Inc. > >> > >> > > > > > > > > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: process inferior-lisp core dumped!
On Monday 05 January 2009 15:30, wubbie wrote: > Hi, > > I got core dump while running > > ... > > user=> # > # An unexpected error has been detected by Java Runtime Environment: > # > # SIGSEGV (0xb) at pc=0x064f7e68, pid=6500, tid=2893822864 > # > # ... > > Process inferior-lisp aborted (core dumped) > > Does it happen once in a while? It does, but it is, by definition, a bug in the JVM / JRE (or in some JNI code). > If interested in the content of the log file, pls let me know. > > Sun You can always report these to Sun (the company, not you...). Randall Schulz --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: process inferior-lisp core dumped!
Ok, I'll do it. Thanks Sun On Jan 5, 6:36 pm, Randall R Schulz wrote: > On Monday 05 January 2009 15:30, wubbie wrote: > > > > > Hi, > > > I got core dump while running > > > ... > > > user=> # > > # An unexpected error has been detected by Java Runtime Environment: > > # > > # SIGSEGV (0xb) at pc=0x064f7e68, pid=6500, tid=2893822864 > > # > > # ... > > > Process inferior-lisp aborted (core dumped) > > > Does it happen once in a while? > > It does, but it is, by definition, a bug in the JVM / JRE (or in some > JNI code). > > > If interested in the content of the log file, pls let me know. > > > Sun > > You can always report these to Sun (the company, not you...). > > Randall Schulz --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: Please submit patches as attachments to issues
Where do I find the Clojure Contributor Agreement so I can submit a patch with my issue? Andrew --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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 two list comprehensions are different?
Perhaps the assert-args macro should be public? Since compile-time verification of your macros is essentially free and it avoids runtime errors that may be pretty difficult to diagnose, it seems to me to be very good practice to check your macro arguments. Something I still do all the time is write: (defn my-fn (arg1 arg2) blah) This is probably due to my weird half background in CL. But anyway, it causes a weird unrelated error where a clear error would state that defn expected a vector of arguments to the function and not a list, you antediluvian fool!. Ditto with let, but it appears that is addressed. A likewise, utterly confounding error is when you defmulti with a dispatch function of the wrong arity. When you call the resultant multi function there was very little connection between the error and where the problem was. Perhaps this could be my little project. How difficult would it be to extend defmethod such that it checked the dispatch function and ensured that the dispatch function had at least the arity of the defmethod function? Chris On Jan 5, 12:38 pm, Chouser wrote: > On Sat, Jan 3, 2009 at 6:20 PM, Olov Lassus wrote: > > >> The 'let' macro already has a similar check. > > >> Attached is a patch that adds even-ness and related assertions to a > >> bunch of core macros. > > > That's better - I applied the patch and it's working as expected here. > > Thanks. I've created an issue for this: > > http://code.google.com/p/clojure/issues/detail?id=31 > > --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: Please submit patches as attachments to issues
Here: http://clojure.org/contributing On Jan 5, 3:39 pm, Andrew Baine wrote: > Where do I find the Clojure Contributor Agreement so I can submit a > patch with my issue? > > Andrew --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: reduction
On Mon, Jan 5, 2009 at 11:37 AM, Christophe Grand wrote: > Stuart, > > Do you think rec-cat, rec-cons and reductions belong to seq-utils? > > Christophe > Find by me. I won't claim ownership over seq-utils or str-utils. As far as I'm concerned, any contrib committers can add to them. -Stuart Sierra --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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 java.ext.dirs to manage the Classpath for Clojure REPLs
On Jan 4, 12:59 pm, "Stephen C. Gilardi" wrote: > In my case, I set the value of java.ext.dirs to a list of just one > directory. That directory contains (relative) symbolic links to all > the Jar files and directories I want Clojure to use as its Classpath. Symlinks! Ack! Terrible visions of asdf-install swim before my eyes! Oh, the pain! Ok, I'm done. Never mind. -S --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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 on side effects
"As the saying goes, a program without side-effects does nothing more than make your CPU hot." http://en.wikibooks.org/wiki/Learning_Clojure http://groups.google.com/group/clojure/browse_thread/thread/fe8e6f306b9891a7/3e35a075ad45571a?lnk=gst&q=learning+clojure#3e35a075ad45571a Posted by Brian W, might be where you came across it in regard to Clojure. On Jan 6, 10:34 am, "Paul Barry" wrote: > I didn't think you originated the quote, but did you mention it during one > of your presentations? Maybe I'm thinking of someone else. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: mset
You might be able to simplify this by having just one Ref containing the global "state" of the game. -S On Jan 4, 12:59 pm, Timothy Pratley wrote: > A while ago I wrote a short MUD which had to keep track of a changing > group of players, and other data. Retrospectively I've developed a > helper which can update in place any mutable map, handles nested > access, and behaves like assoc on immutables. > > It allows usage like so: > ; set up a mutable map of mutable players - tongue twister > (def players (ref nil)) > (mset players "tim" (ref {:str 5 :con 5})) > (mset players "tom" (ref {:str 7 :con 2})) > > ; change some attributes > (mset players "tim" :str 6) > (mset players "tim" :con 4) > (mset players "tim" :friend (@players "tom")) > > ; results in pretty much what you might expect > (println "tim:" @(@players "tim")) > (println "tom:" @(@players "tom")) > (println "tim's friend" @((@players "tim") :friend)) > tim: {:str 6, :con 4} > tom: {:str 7, :con 2} > tim's friend {:str 7, :con 2} > > http://groups.google.com/group/clojure/web/helper.clj > > Working on the deletion side I ran into a bit of a block when trying > to nil refs that were being removed: > > ; dissoc versions > (defmulti mdel (fn [m & args] (class m))) > (defmethod mdel clojure.lang.Ref [v] > (dosync (ref-set v nil))) > (defmethod mdel clojure.lang.Ref [m k & more] > (if more > (apply mdel (@m k) more) > (dosync (mdel (@m k)) > (ref-set m (dissoc @m k > m) > > (mdel (ref 5)) > -> arity exception > > I'm not sure why... I suspect it is something obvious I'm overlooking. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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.sql] Multiple table SELECT problem
Question How can I have clojure-contrib sql execute and return arbitrary SQL SELECT statement? Example This statement: (defn db-read [] (sql/with-connection db (sql/with-results res "SELECT users.id, users.name, roles.name FROM users INNER JOIN roles ON user.id = roles.user_id ORDER BY users.id;" (doseq [rec res] (println rec) (db-read) bombs for me with the follwing exception: java.lang.IllegalStateException: Var scrapbook/db-read is unbound. (NO_SOURCE_FILE:0) I narrowed it down to the reference of the second table as a column. I.e. the following works fine: (defn db-read [] (sql/with-connection db (sql/with-results res "SELECT users.id, users.name, roles.name FROM users INNER JOIN roles ON user.id = roles.user_id ORDER BY users.id;" (doseq [rec res] (println rec) But obviously I don't get all the data I need/want. Any help is appreciated. -ck --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: Math functions
On Jan 3, 2:48 pm, "Mark Engelberg" wrote: > I've noticed that Clojure is missing several math functions that come > standard with most programming languages, especially other > Schemes/Lisps. Many of these functions are available in java's math > library, but only for doubles. Nice work, Mark. Are you on clojure-contrib? This would be a useful addition. -Stuart Sierra --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: Multiple table SELECT problem
Ops, my mistake. Second one should be: (defn db-read [] (sql/with-connection db (sql/with-results res "SELECT users.id, users.name FROM users INNER JOIN roles ON user.id = roles.user_id ORDER BY users.id;" (doseq [rec res] (println rec) Sorry about that, -ck --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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.sql] Multiple table SELECT problem
On Jan 5, 2009, at 7:17 PM, ck wrote: Question How can I have clojure-contrib sql execute and return arbitrary SQL SELECT statement? Example The "works" and "doesn't work" cases you posted appear to be identical. I believe there can be nothing about the SQL in the string that would have any bearing on scrapbook/db-read being defined or not. What could have that effect would be forgetting to close one of the parentheses in the definition of db-read before calling it. Are you using an editor that helps out with matching parentheses? --Steve smime.p7s Description: S/MIME cryptographic signature
Re: Multiple table SELECT problem
On Jan 5, 2009, at 7:59 PM, ck wrote: Ops, my mistake. Second one should be: (defn db-read [] (sql/with-connection db (sql/with-results res "SELECT users.id, users.name FROM users INNER JOIN roles ON user.id = roles.user_id ORDER BY users.id;" (doseq [rec res] (println rec) Sorry about that, In the "doesn't work" case, had you defined db-read in the "scrapbook" namespace? What does "scrapbook/db-read" return when typed at the repl. --Steve smime.p7s Description: S/MIME cryptographic signature
Re: Running out of memory when using filter?
Sorry to resurrect this, but I noticed that there isn't an issue to track this - is this something unlikely to be fixed officially for 1.0 ? The workaround you posted certainly works for me, but I just wanted to make sure the actual core.clj filter implementation receives the fix eventually. On Dec 8 2008, 6:51 pm, Rich Hickey wrote: > On Dec 8, 2008, at 8:56 PM, Stephen C. Gilardi wrote: > > > > > I think I finally see the problem. The "rest expression" infilter's > > call to lazy-cons has a reference to "coll" in it. That's all it > > takes for coll to be retained during the entire calculation of the > > rest. > > > (defnfilter > > "Returns a lazy seq of the items in coll for which > > (pred item) returns true. pred must be free of side-effects." > > [pred coll] > > (when (seq coll) > > (if (pred (first coll)) > > (lazy-cons (first coll) (filterpred (rest coll))) > > (recur pred (rest coll) > > > The stye of fix that occurs to me involves peeling off coll from > > (frest coll) and (rrest coll) before continuing the lazy evaluation. > > > Posting so someone else can beat me to the answer. :-) > > I'm sorry I haven't chimed in sooner. I fully understand this. Yes, > it's the closure over coll in the rest portion, which means that after > finding some match, a subsequent call to rest that needs to skip a lot > will create a window over the interval where the seq will be realized. > > Eagerly evaluating (rest coll) won't work - the result will still be > in the closure while the recursion occurs. The only solutions involve > mutation infilter. Here's one way: > > (defnfilter > [pred coll] > (let [sa (atom (seq coll)) > step (fn step [] > (when-let [s @sa] > (let [x (first s)] > (if (pred x) > (lazy-cons x (do (swap! sa rest) (step))) > (do (swap! sa rest) > (recur))] > (step))) > > But it's not pretty. Fortunately, this segues with work I have been > doing on I/O and generators/streams. This will let you write things > like: > > (defnfilter-stream > "Returns a stream of the items in strm for which > (pred item) returns true. pred must be free of side-effects." > [pred strm] > (stream > #(let [x (next! strm)] > (if (or (eos? x) (pred x)) x (recur) > > (defnfilter > "Returns a lazy seq of the items in coll for which > (pred item) returns true. pred must be free of side-effects." > [pred coll] > (stream-seq (filter-stream pred (stream coll > > I'm still not done with this yet, so anyone who is stuck can use the > former version. > > 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 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 two list comprehensions are different?
On Mon, Jan 5, 2009 at 7:03 PM, chris wrote: > > Perhaps the assert-args macro should be public? I chose to make it private for now to allow the API to morph as needed without making breaking changes. Of course Rich will be the final arbiter of all this. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: Multiple table SELECT problem
Stephen, thanks for pointing out the namespace problem. That fixed the exception mentioned above, which was stupidity on my part. With that I'm able to run (again) the scrapbook=> (db-read) in the second example, i.e. the one without the reference to second table in columns, I get list of maps containing column-names and values back (as expected): {:id 1, :name Test} ... But when the I run the one with the reference to second table in columns, I get java.lang.RuntimeException: java.lang.IllegalArgumentException: Too many arguments to struct constructor (NO_SOURCE_FILE:0) -ck --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: Multiple table SELECT problem
On Jan 5, 2009, at 8:52 PM, ck wrote: Stephen, thanks for pointing out the namespace problem. That fixed the exception mentioned above, which was stupidity on my part. With that I'm able to run (again) the scrapbook=> (db-read) in the second example, i.e. the one without the reference to second table in columns, I get list of maps containing column-names and values back (as expected): {:id 1, :name Test} ... But when the I run the one with the reference to second table in columns, I get java.lang.RuntimeException: java.lang.IllegalArgumentException: Too many arguments to struct constructor (NO_SOURCE_FILE:0) I recommend looking at the output of (.printStackTrace *e) after you get the exception. resultset-seq builds struct maps from the resultset. Would a correct output from this query have two columns whose names are identical? Looking at the implementation of resultset- seq in clojure.core, it looks like that might cause trouble. If that's really the issue, can you work around it in the SQL? --Steve smime.p7s Description: S/MIME cryptographic signature
terminating an app that uses agents
Why doesn't the following code terminate on its own? It outputs the number 6 as expected, but then just hangs. I'm guessing its related to non-daemon threads related to agents that are still running. What's the proper way to exit? (def my-agent (agent 1)) (defn sleep-and-multiply [old-state times ms] (Thread/sleep ms) (* old-state times)) (send-off my-agent sleep-and-multiply 2 1500) (send-off my-agent sleep-and-multiply 3 1000) (await my-agent) (println "my-agent =" @my-agent) -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: Multiple table SELECT problem
Yep, that's it. The two columns with the same name cause the problem. Interestingly enough, the quick fix using roles.name AS role_name does *not* help either. But that give me something to look at, in this case figuring out how 'resultset-seq' works and why it does not use the aliases column name. Thanks for the help, -ck --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: Multiple table SELECT problem
For completeness of the post, here's the stack trace: java.lang.RuntimeException: java.lang.IllegalArgumentException: Too many arguments to struct constructor (NO_SOURCE_FILE:0) at clojure.lang.Compiler.eval(Compiler.java:4179) at clojure.core$eval__3756.invoke(core.clj:1566) at clojure.main$repl__5495$fn__5513.invoke(main.clj:148) at clojure.main$repl__5495.doInvoke(main.clj:145) at clojure.lang.RestFn.invoke(RestFn.java:426) at clojure.main$repl_opt__5537.invoke(main.clj:208) at clojure.main$legacy_repl__5562.invoke(main.clj:249) at clojure.lang.Var.invoke(Var.java:336) at clojure.main.legacy_repl(main.java:29) at clojure.lang.Repl.main(Repl.java:20) Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: Too many arguments to struct constructor at clojure.lang.LazyCons.first(LazyCons.java:44) at clojure.lang.RT.first(RT.java:541) at clojure.core$first__2914.invoke(core.clj:42) at scrapbook$db_read__247$fn__249.invoke(Unknown Source) at clojure.contrib.sql.internal$with_connection_STAR___77.invoke (internal.clj:58) at scrapbook$db_read__247.invoke(Unknown Source) at scrapbook$eval__256.invoke(Unknown Source) at clojure.lang.Compiler.eval(Compiler.java:4168) ... 9 more Caused by: java.lang.IllegalArgumentException: Too many arguments to struct constructor at clojure.lang.PersistentStructMap.construct (PersistentStructMap.java:73) at clojure.core$struct__4047.doInvoke(core.clj:2111) at clojure.lang.RestFn.applyTo(RestFn.java:144) at clojure.core$apply__3040.doInvoke(core.clj:376) at clojure.lang.RestFn.invoke(RestFn.java:443) at clojure.core$resultset_seq__4059$thisfn__4073$fn__4075.invoke (core.clj:2147) at clojure.lang.LazyCons.first(LazyCons.java:40) ... 16 more nil --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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 thread pool
I think I read somewhere that the number of threads in the thread pool used by agents is based on the number of processors available. Is it exactly that number? Is that the number of threads per agent of the total number of threads? -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: agent thread pool
On Mon, Jan 5, 2009 at 10:10 PM, Mark Volkmann wrote: > > I think I read somewhere that the number of threads in the thread pool > used by agents is based on the number of processors available. Is it > exactly that number? Agents currently use one of two thread pools. 'send' uses pooledExecutor and 'send-off' uses soloExecutor. Those are defined here: http://code.google.com/p/clojure/source/browse/trunk/src/jvm/clojure/lang/Agent.java?r=1194#25 You can see that currently pooledExecutor is capped at number of CPUs plus 2, but I wouldn't bet too heavily on that particular formula. > Is that the number of threads per agent of the total number of > threads? I'll assume you mean "or" instead of "of". Each agent only executes at most one action at a time, so having multiple threads per agent doesn't make sense. If you send multiple actions to a single agent, the actions queue up. If you 'send' lots of actions to more than CPUs+2 agents, the agents queue up waiting for an available thread. This is why it's important not to block for IO or for other threads while in a 'send' action, because it can cause other agents to wait unnecessarily. In those cases you should instead use 'send-off'. Each agent will still only do one action at a time, but the soloExecutor pool will grow as needed to give a thread to every agent that has an action queued. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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 -~--~~~~--~~--~--~---
Namespaces and filenames
I created a little file with it's own namespace and the tried to use items form that file in another file. I used :use to import that namespace into the second file but was having a devil of a time getting it to work. It took me a while to riddle out that the file seems to HAVE to be named the same as the namespace! In my case, if my namespace is called foo-bar, than the file have to be named foo_bar.clj. I don't see anywhere in the web site where this is called out so I am wondering if a) I am doing something very wrong or b) the docs on the web site need to be clarified in this regard? Thanx, joe --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: Multiple table SELECT problem
I made a post about this in October, with an attached patch. I guess it got lost in the shuffle. http://groups.google.com/group/clojure/browse_frm/thread/e533e9cdf758f210?q=#43e5775c2d959dc7 I'll file a bug and attach the patch. Allen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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 -~--~~~~--~~--~--~---
(alength nil) => java.lang.IllegalArgumentException: More than one matching method found
I was just messing around with array's and produced the following exception. I don't actually need this to work for any reason, but I was rather surprised by the behavior. Is this a bug or expected behavior? Please note I'm using revision 1195. user=> (alength nil) java.lang.IllegalArgumentException: More than one matching method found: alength (NO_SOURCE_FILE:146) user=> (.printStackTrace *e) java.lang.IllegalArgumentException: More than one matching method found: alength (NO_SOURCE_FILE:146) at clojure.lang.Compiler.analyzeSeq(Compiler.java:4139) at clojure.lang.Compiler.analyze(Compiler.java:3961) at clojure.lang.Compiler.analyze(Compiler.java:3934) at clojure.lang.Compiler.analyzeSeq(Compiler.java:4127) at clojure.lang.Compiler.analyze(Compiler.java:3961) at clojure.lang.Compiler.analyze(Compiler.java:3934) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:3635) at clojure.lang.Compiler$FnMethod.parse(Compiler.java:3474) at clojure.lang.Compiler$FnMethod.access$1100(Compiler.java:3351) at clojure.lang.Compiler$FnExpr.parse(Compiler.java:2937) at clojure.lang.Compiler.analyzeSeq(Compiler.java:4130) at clojure.lang.Compiler.analyze(Compiler.java:3961) at clojure.lang.Compiler.eval(Compiler.java:4166) at clojure.core$eval__3756.invoke(core.clj:1566) at clojure.main$repl__5495$fn__5513.invoke(main.clj:148) at clojure.main$repl__5495.doInvoke(main.clj:145) at clojure.lang.RestFn.invoke(RestFn.java:426) at clojure.main$repl_opt__5537.invoke(main.clj:208) at clojure.main$legacy_repl__5562.invoke(main.clj:249) at clojure.lang.Var.invoke(Var.java:336) at clojure.main.legacy_repl(main.java:29) at clojure.lang.Repl.main(Repl.java:20) Caused by: java.lang.IllegalArgumentException: More than one matching method found: alength at clojure.lang.Compiler.getMatchingParams(Compiler.java:2057) at clojure.lang.Compiler$StaticMethodExpr.(Compiler.java:1264) at clojure.lang.Compiler$HostExpr$Parser.parse(Compiler.java:760) at clojure.lang.Compiler.analyzeSeq(Compiler.java:4132) ... 21 more nil user=> -Ryan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: mset
On Jan 6, 11:21 am, Stuart Sierra wrote: > You might be able to simplify this by having just one Ref containing > the global "state" of the game. Hi Stuart, yes I agree that is the better approach. I went down the 'multi-mutable' path trying to improve relationship handling. Consider two rooms which are 'linked' allowing travel between them. This could be represented with a link id which provided a way to look up what the other room is. However if you wanted to link the rooms themselves, that would be impossible to declare unless you use mutation. But why not just use id lookups? Say room 1 was deleted, now room 2 has an invalid link. Ok so when I delete a room I can find all other rooms that reference it and update them, but what if players reference rooms for their current location? I could update all the relationships but I'm implementing a database. That's not necessarily bad, but it seemed like a lot of work (maybe there is a framework that would make it easy). So how about I just allow invalid ids as they'll just be looked up as nil and I can check for nil in my code. That's really easy, the only downside is that ids cannot be reused or my state will be corrupt. Not really a big deal, but I thought I would try using a mutable instead. With a mutable if I remove a room I can set it to nil and anything linked to it will be unlinked. To remove a link I can nil the link itself (not the target). It is not really a great solution, but it does have the advantage of not requiring any lookup either. On the downside the mutable version has all the drawbacks any mutable brings with it, which I'd like to avoid. I'm interested in any tips about representing relational information. Regards, Tim. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
How do I debug a macro?
I have a macro I am trying to debug but I can't get it to expand. I get the following: java.lang.IncompatibleClassChangeError (NO_SOURCE_FILE:1) [Thrown class clojure.lang.Compiler$CompilerException] The backtrace is useless here as just gives me a lot of internal clojure/java calls, none of which I can expand or in any way directly relate to my macro to figure out the cause. Macroexpand seems to work and give me a proper expansion but I can't see what the deelio is with the code tha is the problem. Thanx, joe --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: How do I debug a macro?
Well, after a lot of staring, it seems the issue was that I wasn't array splicing one of my args so a list was being passed where a function was expected. Is there any way to clean this up so that the error message is a little more direct? On Jan 5, 2009, at 10:05 PM, Joseph Jones wrote: > I have a macro I am trying to debug but I can't get it to expand. I > get the following: > > java.lang.IncompatibleClassChangeError (NO_SOURCE_FILE:1) > [Thrown class clojure.lang.Compiler$CompilerException] > > The backtrace is useless here as just gives me a lot of internal > clojure/java calls, none of which I can expand or in any way > directly relate to my macro to figure out the cause. > > Macroexpand seems to work and give me a proper expansion but I can't > see what the deelio is with the code tha is the problem. > > Thanx, > joe > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: terminating an app that uses agents
You need to remember to ... clojure.core/shutdown-agents ([]) Initiates a shutdown of the thread pools that back the agent system. Running actions will complete, but no new actions will be accepted nil On Tue, Jan 6, 2009 at 3:35 AM, Mark Volkmann wrote: > > Why doesn't the following code terminate on its own? It outputs the > number 6 as expected, but then just hangs. I'm guessing its related to > non-daemon threads related to agents that are still running. What's > the proper way to exit? > > (def my-agent (agent 1)) > > (defn sleep-and-multiply [old-state times ms] > (Thread/sleep ms) > (* old-state times)) > > (send-off my-agent sleep-and-multiply 2 1500) > (send-off my-agent sleep-and-multiply 3 1000) > (await my-agent) > (println "my-agent =" @my-agent) > > -- > R. Mark Volkmann > Object Computing, Inc. > > > > -- Venlig hilsen / Kind regards, Christian Vest Hansen. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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 -~--~~~~--~~--~--~---