Re: drop-while and (pred item) returns nil?
By the way, I cloned the Clojure repo and have adjusted the docs for this function, but I can't figure out how to get Github to submit it for approval, or for a pull request or whatever it is. If someone wants to take this patch and check it in for me, that would be fine too. diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj index eaab3aa..ef05ccb 100644 --- a/src/clj/clojure/core.clj +++ b/src/clj/clojure/core.clj @@ -2451,7 +2451,7 @@ (defn drop-while Returns a lazy sequence of the items in coll starting from the first - item for which (pred item) returns nil. + item for which (pred item) returns logical false. {:added 1.0 :static true} [pred coll] On Sep 9, 11:46 pm, Jacek Laskowski ja...@laskowski.net.pl wrote: On Fri, Sep 10, 2010 at 1:08 AM, Alan a...@malloys.org wrote: I'm not 100% sure what you're asking, but I think I understand you, and in that case you can refer to http://groups.google.com/group/clojure/browse_thread/thread/9c7f72670..., in which I ask this very question and get the answers I am looking for. Hi Alan, That was my point exactly - the reference to nil in the docstring for drop-while. It's a bit confusing to me and I'd expect a boolean reference instead. Jacek -- Jacek Laskowski Notatnik Projektanta Java EE -http://jaceklaskowski.pl -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: drop-while and (pred item) returns nil?
Hi, On 13 Sep., 08:22, Alan a...@malloys.org wrote: By the way, I cloned the Clojure repo and have adjusted the docs for this function, but I can't figure out how to get Github to submit it for approval, or for a pull request or whatever it is. If someone wants to take this patch and check it in for me, that would be fine too. The usual approach is detailed here: http://clojure.org/patches. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojurescript and 1.2.0
Hi, I soon realised that applying the patch won't be easy... After going through the different rejected diffs, I realised I wasn't going to manage to make it work. I switched to Parenscript for my small JS project, even if I's rather have used Clojure than CL (especially a very small subste of CL) I agree it will be a better idea to wait for Clojure-in-Clojure. Could you mail the list, when you want to start working back on this? I would really be happy to help you with the clojurization of clojurescript if you need more hands... Best regards, Nicolas. On Mon, Sep 13, 2010 at 5:59 AM, Chouser chou...@gmail.com wrote: On Sun, Sep 12, 2010 at 9:04 AM, Nicolas Oury nicolas.o...@gmail.com wrote: Oooops. Ansered my question. Haven't seen the patch in the git repository. Will try to apply it to clojure 1.2. I imagine you'll have some difficulty with that. ClojureScript was last updated to work with Clojure 1.0 (with the patch applied) ... or perhaps even an earlier version than that. I've given up working on it until more of Clojure-in-Clojure is complete, which will make bringing ClojureScript up to date and keeping it there dramatically easier. --Chouser http://joyofclojure.com/ -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- Sent from an IBM Model M, 15 August 1989. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ns-unmap-all
Yes. And you should consider wrapping the call to map into (dorun) so that you're sure that once the function exits, all the ns-umap calls are done. 2010/9/12 Robert McIntyre r...@mit.edu shouldn't we rename remove-ns to ns-remove to keep it in line with the other ns functions? --Robert McIntyre On Sun, Sep 12, 2010 at 4:18 PM, Phil Hagelberg p...@hagelb.org wrote: On Sat, Sep 11, 2010 at 6:48 PM, blais martin.bl...@gmail.com wrote: The following function has been a real _lifesaver_ lately in debugging symbol collisions in (ns) directives when developing with SLIME in a long-running VM: (defn ns-unmap-all Unmap all the symbols (except 'ns' and 'in-ns'). ([] (ns-unmap-all *ns*)) ([ns] (map #(ns-unmap ns %) (keys (ns-map ns) May I kindly suggest the inclusion of something similar along with all the other core namespace functions? It's quite nice (IMHO: necessary) to be able to get back to a clean environment when you face a collision error. (I'm guessing may of you have something similar already defined in your environments.) I've had this on my todo list for swank-clojure for a while now; would love to see a patch that integrates it. Not sure it belongs in clojure.core though. -Phil -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ns-unmap-all
Hi, On 13 Sep., 09:39, Laurent PETIT laurent.pe...@gmail.com wrote: And you should consider wrapping the call to map into (dorun) so that you're sure that once the function exits, all the ns-umap calls are done. (defn ns-unmap-all Unmap all the symbols (except 'ns' and 'in-ns'). ([] (ns-unmap-all *ns*)) ([ns] (map #(ns-unmap ns %) (keys (ns-map ns) In fact you should use doseq. dorun is so ugly. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ns-unmap-all
indeed 2010/9/13 Meikel Brandmeyer m...@kotka.de Hi, On 13 Sep., 09:39, Laurent PETIT laurent.pe...@gmail.com wrote: And you should consider wrapping the call to map into (dorun) so that you're sure that once the function exits, all the ns-umap calls are done. (defn ns-unmap-all Unmap all the symbols (except 'ns' and 'in-ns'). ([] (ns-unmap-all *ns*)) ([ns] (map #(ns-unmap ns %) (keys (ns-map ns) In fact you should use doseq. dorun is so ugly. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Possible bug in with-symbol-macros, interacts badly with case
I digged a little and I have a patch. I modified the case* parser in Compiler.java, so the patch shouldn't affect anything else: I prefer keeping safe since my knowledge of Clojure internals is limited, but a more radical solution might be desirable. The problem seems caused by the way case* gets constructed. The 7th parameter is a hash-map that is passed directly to the compiler (Compiler.java). The values of this hash-map are instances of the MapEntry class. When a case call is macroexpanded, those MapEntry instances get printed out as vectors. When they are read back and evaluated, they become instances of PersistentVector and the compiler barfs. Since case* arguments are not evaluated there's no way, as far as I know, to pass a MapEntry object to case* by calling it directly since there's no such thing as a MapEntry literal. My patch modifies case* so that it can handle a PersistentVector and make a new MapEntry from it. I'll post the patch here directly, since it's only a few lines long. I hope it's not too rude. It's against git master branch. --- Compiler.java.orig 2010-09-11 14:35:07.0 +0200 +++ Compiler.java 2010-09-13 12:12:12.033621364 +0200 @@ -7445,7 +7445,13 @@ { Map.Entry e = (Map.Entry) o; Integer minhash = ((Number)e.getKey()).intValue(); - MapEntry me = (MapEntry) e.getValue(); + MapEntry me = null; + if (e.getValue() instanceof PersistentVector) { + PersistentVector pv = (PersistentVector) e.getValue(); + me = new MapEntry(pv.nth(0), pv.nth(1)); + } else { + me = (MapEntry) e.getValue(); + } -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojurescript and 1.2.0
Thanks for the link. Very interesting indeed. Didn't know about it. On Mon, Sep 13, 2010 at 11:38 AM, Daniel Werner daniel.d.wer...@googlemail.com wrote: On Sep 13, 9:40 am, Nicolas Oury nicolas.o...@gmail.com wrote: I switched to Parenscript for my small JS project, even if I's rather have used Clojure than CL (especially a very small subste of CL) There is also Scriptjure, which is basically JavaScript with Clojury syntax, similar to what ParenScript does for CL: http://github.com/arohner/scriptjure -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- Sent from an IBM Model M, 15 August 1989. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
[CfP 4th European Lisp Symposium, Hamburg, March 31st - April 1st 2011
~~ 4th European Lisp Symposium Special Focus on Parallelism Efficiency March 31 - April 1st, 2011 TUHH, Hamburg University of Technology Hamburg, Germany http://www.european-lisp-symposium.org/ ~~ Important Dates + Submission Deadline: January 09, 2011 + Author Notification: February 06, 2011 + Final Paper Due: February 28, 2011 + Symposium: March 31 - April 1st, 2011 Authors of accepted research contributions will be invited to submit an extended version of their papers for journal publication. Scope ~~ The purpose of the European Lisp Symposium is to provide a forum for the discussion and dissemination of all aspects of design, implementation and application of any of the Lisp dialects, including Common Lisp, Scheme, Emacs Lisp, AutoLisp, ISLISP, Dylan, Clojure, ACL2, ECMAScript, Racket and so on. We encourage everyone interested in Lisp to participate. The European Lisp Symposium 2011 invites high quality papers about novel research results, insights and lessons learned from practical applications, and educational perspectives. We also encourage submissions about known ideas as long as they are presented in a new setting and/or in a highly elegant way. This year's focus will be directed towards Parallelism Efficiency. We especially invite submissions in the following areas: + Parallel and distributed computing + Code generation for multi-core architectures + Code generation for HTM + Large and ultra-large systems + Optimization techniques + Embedded applications Contributions are also welcome in other areas, including but not limited to: + Context-, aspect-, domain-oriented and generative programming + Macro-, reflective-, meta- and/or rule-based development approaches + Language design and implementation + Language integration, inter-operation and deployment + Development methodologies, support and environments + Educational approaches and perspectives + Experience reports and case studies Technical Program: ~~ We invite submissions in the following forms: * Papers: Technical papers of up to 15 pages that describe original results or explain known ideas in new and elegant ways. * Demonstrations: Abstracts of up to 4 pages for demonstrations of tools, libraries, and applications. * Tutorials: Abstracts of up to 4 pages for in-depth presentations about topics of special interest for at least 90 minutes and up to 180 minutes. * Lightning talks: Abstracts of up to one page for talks to last for no more than 5 minutes. All submissions should be formatted following the ACM SIGS guidelines and include ACM classification categories and terms. For more information on the submission guidelines and the ACM keywords, see: http://www.acm.org/sigs/publications/proceedings-templates http://www.acm.org/about/class/1998 Submissions should be uploaded to Easy Chair, at the following address: http://www.easychair.org/conferences/?conf=els2011 Programme Chair Didier Verna - EPITA Research and Development Laboratory, France Local Chair Ralf Moeller - Hamburg University of Technology, Germany Programme Committee Antonio Leitao - Instituto Superior Tecnico/INESC-ID, Portugal Christophe Rhodes - Goldsmiths College, University of London, UK David Edgar Liebke - Relevance Inc., USA Didier Verna - EPITA Research and Development Laboratory, France Henry Lieberman - MIT Media Laboratory, USA Jay McCarthy - Brigham Young University, USA Jose Luis Ruiz Reina - Universidad de Sevilla, Spain Marco Antoniotti - Universita Milano Bicocca, Italy Manuel Serrano - INRIA, France Michael Sperber - DeinProgramm, Germany Pascal Costanza - Vrije Universiteit of Brussel, Belgium Scott McKay - ITA Software, USA -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
ANN: 28 September London Clojure Dojo
London Clojurians and those who could be in London! I've created a sign up for the next London Clojure Dojo. It will be on 28 September starting at 7PM at ThoughtWorks. The sign up page is here: http://3.ly/0910ldncljdojo We meet every month to learn a bit more clojure (and often a bit of emacs or other editors) through writing clojure, watching others write clojure and talking about clojure. Everyone is welcome. I hope to see you there. cheers, Bruce -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Compojure
Hi list, I'm trying to get a simple hello world Compojure application running. I attach both the clj file and maven pom.xml (using NetBeans+Enclojure). When I run (guestbook.core/-main), I get a blank page in browser, no matter the URL. What am I missing? BTW, by blank I really mean blank. If I view the page source in Firefox, it's empty. TIA, -- Bahman Movaqar (http://BahmanM.com) ERP Evaluation, Implementation Deployment Consultant PGP Key ID: 0x3750102D (keyserver2.pgp.com) ?xml version=1.0 encoding=UTF-8? project xmlns=http://maven.apache.org/POM/4.0.0; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd; properties clojure.version1.2.0/clojure.version project.build.sourceEncodingUTF-8/project.build.sourceEncoding /properties modelVersion4.0.0/modelVersion version0.0.1/version nameGuestBook/name descriptionGuestBook/description build sourceDirectorysrc/main/clojure/sourceDirectory testSourceDirectorysrc/test/clojure/testSourceDirectory resources resource directorysrc/main/clojure/directory /resource resource directorysrc/main/resources/directory /resource /resources testResources testResource directorysrc/test/clojure/directory /testResource /testResources plugins plugin groupIdcom.theoryinpractise/groupId artifactIdclojure-maven-plugin/artifactId version1.3.2/version configuration sourceDirectories sourceDirectorysrc/main/clojure/sourceDirectory /sourceDirectories clojureOptions-Xmx1G/clojureOptions /configuration executions execution idcompile-clojure/id phasecompile/phase goals goalcompile/goal /goals /execution /executions /plugin plugin groupIdorg.apache.maven.plugins/groupId artifactIdmaven-compiler-plugin/artifactId configuration source1.6/source target1.6/target encoding${project.build.sourceEncoding}/encoding showDeprecationtrue/showDeprecation /configuration /plugin plugin groupIdorg.apache.maven.plugins/groupId artifactIdmaven-resources-plugin/artifactId version2.2/version configuration encoding${project.build.sourceEncoding}/encoding /configuration /plugin /plugins /build repositories repository idcentral/id urlhttp://repo1.maven.org/maven2/url /repository repository idclojure-releases/id urlhttp://build.clojure.org/releases/url /repository repository idincanter/id urlhttp://repo.incanter.org/url /repository repository idclojure-snapshots/id urlhttp://build.clojure.org/snapshots/url /repository repository idclojars/id urlhttp://clojars.org/repo//url /repository /repositories dependencies dependency groupIdorg.clojure/groupId artifactIdclojure/artifactId version${clojure.version}/version /dependency dependency groupIdorg.clojure/groupId artifactIdclojure-contrib/artifactId version${clojure.version}/version /dependency dependency groupIdswank-clojure/groupId artifactIdswank-clojure/artifactId version1.2.1/version exclusions exclusion groupIdorg.clojure/groupId artifactIdclojure/artifactId /exclusion exclusion groupIdorg.clojure/groupId artifactIdclojure-contrib/artifactId /exclusion /exclusions /dependency dependency groupIdcompojure/groupId artifactIdcompojure/artifactId version0.4.1/version /dependency dependency groupIdring/groupId artifactIdring-jetty-adapter/artifactId version0.2.6/version /dependency /dependencies groupIdguestbook/groupId artifactIdguestbook/artifactId /project (ns guestbook.core (:gen-class) (:use compojure.core) (:require
Re: Compojure
Try the following instead (just modified your attached source) (ns guestbook.core (:use compojure.core) (:require [compojure.route :as route]) (:require [ring.adapter.jetty :as jetty]) (defroutes dispatcher (GET / [] h1Hello, world/h1) (route/not-found bRequested resource not found/b)) (defn -main [ args] (jetty/run-jetty dispatcher {:port 8080})) You don't need the gen class or the servlet stuff. Also note that there is a compojure google group that you can join to ask more specific compojure based questions on. If you want to see more examples I have some on github at http://github.com/abedra/clojure-web. Cheers, Aaron On 9/12/10 8:53 PM, Bahman Movaqar wrote: Hi list, I'm trying to get a simple hello world Compojure application running. I attach both the clj file and maven pom.xml (using NetBeans+Enclojure). When I run (guestbook.core/-main), I get a blank page in browser, no matter the URL. What am I missing? BTW, by blank I really mean blank. If I view the page source in Firefox, it's empty. TIA, -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Compojure
On 2010/9/13 17:11, Aaron Bedra wrote: Try the following instead (just modified your attached source) (ns guestbook.core (:use compojure.core) (:require [compojure.route :as route]) (:require [ring.adapter.jetty :as jetty]) (defroutes dispatcher (GET / [] h1Hello, world/h1) (route/not-found bRequested resource not found/b)) (defn -main [ args] (jetty/run-jetty dispatcher {:port 8080})) It works. Strange gotcha. You don't need the gen class or the servlet stuff. Also note that there is a compojure google group that you can join to ask more specific compojure based questions on. If you want to see more examples I have some on github at http://github.com/abedra/clojure-web. Oh, I didn't know about the Compojure group.Just joined it. Also nice tutorials for a person like me. Lately, I've been wandering around Clojure corners with no fruit. I plan to write a business suite with Clojure and I think web programming is a good starting point for my case. The tutorials show me what I want to see: how to build web apps step by step. Thank you for the assist and hints Aaron. Much appreciated. On 9/12/10 8:53 PM, Bahman Movaqar wrote: Hi list, I'm trying to get a simple hello world Compojure application running. I attach both the clj file and maven pom.xml (using NetBeans+Enclojure). When I run (guestbook.core/-main), I get a blank page in browser, no matter the URL. What am I missing? BTW, by blank I really mean blank. If I view the page source in Firefox, it's empty. -- Bahman Movaqar (http://BahmanM.com) ERP Evaluation, Implementation Deployment Consultant PGP Key ID: 0x3750102D (keyserver2.pgp.com) signature.asc Description: OpenPGP digital signature
java interop problem
I'm having a problem with java interop using one of the libraries in the Incanter package. When I run the following code: (use '(incanter core charts)) (import (edu.emory.mathcs.jtransforms.fft FloatFFT_2D)) (def xt (make-array Double/TYPE 3 3 )) (for [x (range 3) y (range 3)] (aset xt x y 1)) (.realForward (FloatFFT_2D. 3 3) xt) I get this error: java.lang.IllegalArgumentException: No matching method found: realForward for class edu.emory.mathcs.jtransforms.fft.FloatFFT_2D That code is calling this method: http://incanter.org/docs/parallelcolt/api/edu/emory/mathcs/jtransforms/fft/FloatFFT_2D.html#realForward%28float[][]%29 But if I do the same thing but call this method instead which takes a 1d array as an argument instead it works: http://incanter.org/docs/parallelcolt/api/edu/emory/mathcs/jtransforms/fft/FloatFFT_2D.html#realForward%28float[]%29 I'm pretty new to Clojure so I'm not sure what's going on here, but I guess this has something to do with reflection? Is this going to be a general problem with passing multidimensional arrays to Java methods from Clojure? Thanks, -Ranjit -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: java interop problem
Hi, On 13 Sep., 15:07, Ranjit Chacko rjcha...@gmail.com wrote: (for [x (range 3) y (range 3)] (aset xt x y 1)) Note that that this will not do what you think it does. for creates a lazy sequence which is thrown away immediately. So the aset calls are never done. for is a list comprehension, not a looping construct. Replace for with doseq. As a rule of thumb: side-effects = command starting in do. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: java interop problem
Thanks Armando for catching my stupid mistake. That fixed everything. Meikel, I'm not sure I understand what you're saying. When I evaluate this in the REPL (for [x (range 2) y (range 2)] (aset xt x y (+ x y))) (aget xt 0 0) (aget xt 1 1) I get back 0 and 2 as I expect. Isn't the call to aset consuming the lazy sequence? Thanks. On Sep 13, 11:00 am, Meikel Brandmeyer m...@kotka.de wrote: Hi, On 13 Sep., 15:07, Ranjit Chacko rjcha...@gmail.com wrote: (for [x (range 3) y (range 3)] (aset xt x y 1)) Note that that this will not do what you think it does. for creates a lazy sequence which is thrown away immediately. So the aset calls are never done. for is a list comprehension, not a looping construct. Replace for with doseq. As a rule of thumb: side-effects = command starting in do. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: possible bug
it was on 1.2.0-master but I will upgrade to 1.3.0-master thanks! :-) On Sep 13, 3:01 am, Chouser chou...@gmail.com wrote: On Sun, Sep 12, 2010 at 3:58 PM, doc mdpendergr...@gmail.com wrote: Hello, I am relatively new to clojure and lispy languages in general. I wrote a small program that manipulated thread vars using the binding macro and I am seeing what seems to be strange behavior. To illustrate, here is another small program that reproduces what I am seeing (without all the distraction of the original). There is a reason for the nested bindings in the original code where it seems a bit contrived here. Regardless, if it is something I am doing wrong, please let me know. (declare x y) (def rnd1 (java.util.Random.)) (def rnd2 (java.util.Random.)) (defn throw-random-exception [c] (let [value (.nextInt rnd1 100)] (if (= value 50) (throw (Exception. (str Random Exception after count = c)) (defn change-value-of-thread-local-var [] (set! x (conj x (.nextInt rnd2 100 (defn test-binding [] (binding [x [0 1 2 3 4 5 6]] (try (loop [c 0] (do (change-value-of-thread-local-var) (throw-random-exception c)) (recur (inc c))) (catch Exception e (println (str x \n (.getMessage e))) (defn test-nested-binding [] (binding [x [0 1 2 3 4 5 6]] (try (loop [c 0] (binding [y [7 8 9]] (do (change-value-of-thread-local-var) (throw-random-exception c)) (recur (inc c (catch Exception e (println (str x \n (.getMessage e))) If I load this as a file at the REPL and then run (test-binding) the value of x is unbound when the function returns. However if you run (test-nested-binding) then the value of BOTH x and y have a bound value when the function returns. Is this a bug? If so, where do I report it? If not, what am I doing wrong? I have also moved the binding of x inside the try and it has the same behavior. For me, x and y are unbound after running either function on a recent master branch of Clojure. What version of Clojure are you using? user= (clojure-version) 1.3.0-master-SNAPSHOT If you're using something earlier than the 1.2 release, I'd suggest you upgrade to 1.2 and try again. --Chouserhttp://joyofclojure.com/ -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: java interop problem
The REPL automatically realizes the lazy sequence in the process of printing it out, but if you try to us On Mon, Sep 13, 2010 at 11:07 AM, Ranjit rjcha...@gmail.com wrote: Thanks Armando for catching my stupid mistake. That fixed everything. Meikel, I'm not sure I understand what you're saying. When I evaluate this in the REPL (for [x (range 2) y (range 2)] (aset xt x y (+ x y))) (aget xt 0 0) (aget xt 1 1) I get back 0 and 2 as I expect. Isn't the call to aset consuming the lazy sequence? Thanks. On Sep 13, 11:00 am, Meikel Brandmeyer m...@kotka.de wrote: Hi, On 13 Sep., 15:07, Ranjit Chacko rjcha...@gmail.com wrote: (for [x (range 3) y (range 3)] (aset xt x y 1)) Note that that this will not do what you think it does. for creates a lazy sequence which is thrown away immediately. So the aset calls are never done. for is a list comprehension, not a looping construct. Replace for with doseq. As a rule of thumb: side-effects = command starting in do. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: java interop problem
Erg, gmail hiccup. Started to say if you try to use it in code that's *not* being called from the REPL, you'll be scratching your head trying to figure out why aset never gets called. Mark On Mon, Sep 13, 2010 at 12:27 PM, Mark Nutter manutte...@gmail.com wrote: The REPL automatically realizes the lazy sequence in the process of printing it out, but if you try to us On Mon, Sep 13, 2010 at 11:07 AM, Ranjit rjcha...@gmail.com wrote: Thanks Armando for catching my stupid mistake. That fixed everything. Meikel, I'm not sure I understand what you're saying. When I evaluate this in the REPL (for [x (range 2) y (range 2)] (aset xt x y (+ x y))) (aget xt 0 0) (aget xt 1 1) I get back 0 and 2 as I expect. Isn't the call to aset consuming the lazy sequence? Thanks. On Sep 13, 11:00 am, Meikel Brandmeyer m...@kotka.de wrote: Hi, On 13 Sep., 15:07, Ranjit Chacko rjcha...@gmail.com wrote: (for [x (range 3) y (range 3)] (aset xt x y 1)) Note that that this will not do what you think it does. for creates a lazy sequence which is thrown away immediately. So the aset calls are never done. for is a list comprehension, not a looping construct. Replace for with doseq. As a rule of thumb: side-effects = command starting in do. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Quirk of Map destructuring
On Sep 12, 10:44 pm, Meikel Brandmeyer m...@kotka.de wrote: Hi, On 13 Sep., 04:30, Robert McIntyre r...@mit.edu wrote: Unless there's a good reason for :or to work the way it does I think that would be a good idea, since then you can define default maps somewhere else and use those both with the :or keyword or when calling the function itself. The default map specifies the default for the symbols which are bound, not the source of the values. (let [{foo :some-key bar some-other-key :or {foo 1}} ] ...) Sorry Meikel, I don't understand your answer. My question was why does the default map not lookup the values using the same lookup method as the original map (:keys, :strs, or :syms)? Why does it always assume symbols for keys? If you want to provide defaults from outside the function use merge. (fn-which-does-destructuring (merge defaults-map payload-map)) This sounds like it could be a partial answer but also sounds like it could be very inefficient in the case where you have a very large default map. I don't want to create a new map which merges my data map and my huge default map; I just want to lookup things in the default map in the same way I lookup things in my data map. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Quirk of Map destructuring
On Mon, Sep 13, 2010 at 12:37 PM, Tom Hicks hickstoh...@gmail.com wrote: On Sep 12, 10:44 pm, Meikel Brandmeyer m...@kotka.de wrote: The default map specifies the default for the symbols which are bound, not the source of the values. (let [{foo :some-key bar some-other-key :or {foo 1}} ] ...) Sorry Meikel, I don't understand your answer. My question was why does the default map not lookup the values using the same lookup method as the original map (:keys, :strs, or :syms)? Why does it always assume symbols for keys? What he's saying is that the map after the :or is not doing a lookup in the original map you're destructuring, so it's not a question of doing the same kind of lookup or not. The map after the :or is a map of local symbols to default values (as opposed to being a map of keys-found-in-the-original-map to default values. (let [foo bar] ...) Assigns the value of bar to the local symbol foo (let [{:keys [foo]} {:foo bar}] ...) Assigns the string bar to the local symbol foo by looking up the keyword :foo in the supplied map (let[{:keys [foo baz] :or {baz quux}} {:foo bar}]...) The tricky bit: it looks up the key :foo in the supplied map, and creates a local symbol foo with the value bar. Next, it looks up the keyword :baz (which is nil) and creates a local symbol named baz that is also nil. At this point, it's done looking things up in the supplied map. Now we're up to the :or part. For each local symbol with a nil value, we look in the :or map to see if there's a key with the same symbol. If there is, we use that as the value of the local symbol instead of nil. But the point is we're looking up local symbols now, not anything in the original map. Caveat: that's a high-level overview from a fairly new Clojure user (me) who is only attempting to rephrase what he thinks he's understood from reading the words of people who know what they're talking about. The source code for :or destructuring may use a different process completely, or I may have been more or less correct. I don't really know, but if I've mangled anything I'm hopeful someone will correct me. Cheers. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Interesting Paper on Macros
On Sun, Sep 12, 2010 at 7:15 AM, Randy Hudson randy_hud...@mac.com wrote: Haven't read the whole thing yet, but it seems promising. it is apparently in Racket already, so it isn't just ivory-tower-vapor-ware, either. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Compojure
On 13 September 2010 13:54, Bahman Movaqar b.mova...@gmail.com wrote: It works. Strange gotcha. Ring uses handler functions rather than Java servlets to represent web applications. A Ring adapter takes a handler and a map of options, and starts an inline webserver. The ring.util.servlet library provides a way of turning handlers into servlets, but this is intended only to provide compatibility with existing Java webservers. Oh, I didn't know about the Compojure group. Just joined it. Also nice tutorials for a person like me. Lately, I've been wandering around Clojure corners with no fruit. I plan to write a business suite with Clojure and I think web programming is a good starting point for my case. The tutorials show me what I want to see: how to build web apps step by step. I've started writing up some additional information in the Ring and Compojure Github wikis. They are far from complete (I only started them a few days ago), but you may find them useful. - James -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: java interop problem
Ranjit, try the following to see it in action even at the REPL: (def xt (make-array Float/TYPE 3 3)) (def myloop (for [x (range 3) y (range 3)] (aset xt x y 1))) (aget xt 1 1) ;; xt hasn't been changed myloop ;; force REPL to de-lazify (aget xt 1 1) ;; changed now On Sep 13, 9:28 am, Mark Nutter manutte...@gmail.com wrote: Erg, gmail hiccup. Started to say if you try to use it in code that's *not* being called from the REPL, you'll be scratching your head trying to figure out why aset never gets called. Mark On Mon, Sep 13, 2010 at 12:27 PM, Mark Nutter manutte...@gmail.com wrote: The REPL automatically realizes the lazy sequence in the process of printing it out, but if you try to us On Mon, Sep 13, 2010 at 11:07 AM, Ranjit rjcha...@gmail.com wrote: Thanks Armando for catching my stupid mistake. That fixed everything. Meikel, I'm not sure I understand what you're saying. When I evaluate this in the REPL (for [x (range 2) y (range 2)] (aset xt x y (+ x y))) (aget xt 0 0) (aget xt 1 1) I get back 0 and 2 as I expect. Isn't the call to aset consuming the lazy sequence? Thanks. On Sep 13, 11:00 am, Meikel Brandmeyer m...@kotka.de wrote: Hi, On 13 Sep., 15:07, Ranjit Chacko rjcha...@gmail.com wrote: (for [x (range 3) y (range 3)] (aset xt x y 1)) Note that that this will not do what you think it does. for creates a lazy sequence which is thrown away immediately. So the aset calls are never done. for is a list comprehension, not a looping construct. Replace for with doseq. As a rule of thumb: side-effects = command starting in do. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Quirk of Map destructuring
Right, but the :or could conceptually just merge the supplied map with the actual supplied argument map instead -- it's just another way it could go. This is possibly a simpler model to manage in your head, since presumably you have some idea of how you want to call the function when you're writing it. I'm wondering why the symbol route was selected when the merge way may be more convenient, or why there's something really bad about the merge way that I'm overlooking. --Robert McIntyre On Mon, Sep 13, 2010 at 1:08 PM, Mark Nutter manutte...@gmail.com wrote: On Mon, Sep 13, 2010 at 12:37 PM, Tom Hicks hickstoh...@gmail.com wrote: On Sep 12, 10:44 pm, Meikel Brandmeyer m...@kotka.de wrote: The default map specifies the default for the symbols which are bound, not the source of the values. (let [{foo :some-key bar some-other-key :or {foo 1}} ] ...) Sorry Meikel, I don't understand your answer. My question was why does the default map not lookup the values using the same lookup method as the original map (:keys, :strs, or :syms)? Why does it always assume symbols for keys? What he's saying is that the map after the :or is not doing a lookup in the original map you're destructuring, so it's not a question of doing the same kind of lookup or not. The map after the :or is a map of local symbols to default values (as opposed to being a map of keys-found-in-the-original-map to default values. (let [foo bar] ...) Assigns the value of bar to the local symbol foo (let [{:keys [foo]} {:foo bar}] ...) Assigns the string bar to the local symbol foo by looking up the keyword :foo in the supplied map (let[{:keys [foo baz] :or {baz quux}} {:foo bar}]...) The tricky bit: it looks up the key :foo in the supplied map, and creates a local symbol foo with the value bar. Next, it looks up the keyword :baz (which is nil) and creates a local symbol named baz that is also nil. At this point, it's done looking things up in the supplied map. Now we're up to the :or part. For each local symbol with a nil value, we look in the :or map to see if there's a key with the same symbol. If there is, we use that as the value of the local symbol instead of nil. But the point is we're looking up local symbols now, not anything in the original map. Caveat: that's a high-level overview from a fairly new Clojure user (me) who is only attempting to rephrase what he thinks he's understood from reading the words of people who know what they're talking about. The source code for :or destructuring may use a different process completely, or I may have been more or less correct. I don't really know, but if I've mangled anything I'm hopeful someone will correct me. Cheers. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Quirk of Map destructuring
Hi, Am 13.09.2010 um 20:54 schrieb Robert McIntyre: I'm wondering why the symbol route was selected when the merge way may be more convenient, or why there's something really bad about the merge way that I'm overlooking. I find the the symbol way more consist with the different usage possibilities. {:keys [a] :or {a :x}} {:syms [a] :or {a :x}} {:strs [a] :or {a :x}} {a 1 :or {a :x}} No special cases. Just one thing to remember. And easier to parse. Compare to: {a 1 :or {1 :x}} It is not clear what 1 refers to. You have to check also the rest of the destructuring to understand it, while :or {a :x} is pretty much self-explaining. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure 1.2 Release
Can we get a status update on that :) ? On Aug 19, 3:22 pm, Mark Derricutt m...@talios.com wrote: I think I can do that - or at least push that along. Will check into it when I get to the office in about 30 minutes. PS: Direct sync to central is easy via oss.sonatype.org repositories. -- Pull me down under... On Fri, Aug 20, 2010 at 6:42 AM, Stuart Sierra the.stuart.sie...@gmail.comwrote: We don't have a direct sync to Maven central. They don't seem to be giving those out anymore. So someone with the authority will have to upload it manually. :( -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Talk at QCon SP
Last night, I had the chance to talk about some of the technologies I've put together in a recent project. In particular, it's about mixing clojure + cqrs + event sourcing + cep. I made slides available at http://tinyurl.com/pedroqcon -- and I'll soon publish a sample demo on github. (cheers) ps: there were a few people interested in learning about clojure, and I'll try to arrange some local dojo meetings. So if there is anyone in Rio (Brazil) interested, drop an e-mail so we can make it happen. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure 1.2 Release
I spent some time looking at this yesterday - I just need to create a -sources.jar and a javadoc.jar to satisfy the enforcer rules on the oss.sonatype.org repository deployment process. I'll take another stab tonight see where I get. Mark -- Pull me down under... On Tue, Sep 14, 2010 at 8:04 AM, Warren Wood warrenthomasw...@yahoo.comwrote: Can we get a status update on that :) ? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: possible bug
I sent a reply earlier but I don't think it went through. I tried it again with 1.3.0-master-SNAPSHOT and it still had x and y bound after the test-nested-binding function ran. Not sure what I am doing wrong or have misconfigured? Any insight would be appreciated. take care, Mike On Sep 13, 11:37 am, doc mdpendergr...@gmail.com wrote: it was on 1.2.0-master but I will upgrade to 1.3.0-master thanks! :-) On Sep 13, 3:01 am, Chouser chou...@gmail.com wrote: On Sun, Sep 12, 2010 at 3:58 PM, doc mdpendergr...@gmail.com wrote: Hello, I am relatively new to clojure and lispy languages in general. I wrote a small program that manipulated thread vars using the binding macro and I am seeing what seems to be strange behavior. To illustrate, here is another small program that reproduces what I am seeing (without all the distraction of the original). There is a reason for the nested bindings in the original code where it seems a bit contrived here. Regardless, if it is something I am doing wrong, please let me know. (declare x y) (def rnd1 (java.util.Random.)) (def rnd2 (java.util.Random.)) (defn throw-random-exception [c] (let [value (.nextInt rnd1 100)] (if (= value 50) (throw (Exception. (str Random Exception after count = c)) (defn change-value-of-thread-local-var [] (set! x (conj x (.nextInt rnd2 100 (defn test-binding [] (binding [x [0 1 2 3 4 5 6]] (try (loop [c 0] (do (change-value-of-thread-local-var) (throw-random-exception c)) (recur (inc c))) (catch Exception e (println (str x \n (.getMessage e))) (defn test-nested-binding [] (binding [x [0 1 2 3 4 5 6]] (try (loop [c 0] (binding [y [7 8 9]] (do (change-value-of-thread-local-var) (throw-random-exception c)) (recur (inc c (catch Exception e (println (str x \n (.getMessage e))) If I load this as a file at the REPL and then run (test-binding) the value of x is unbound when the function returns. However if you run (test-nested-binding) then the value of BOTH x and y have a bound value when the function returns. Is this a bug? If so, where do I report it? If not, what am I doing wrong? I have also moved the binding of x inside the try and it has the same behavior. For me, x and y are unbound after running either function on a recent master branch of Clojure. What version of Clojure are you using? user= (clojure-version) 1.3.0-master-SNAPSHOT If you're using something earlier than the 1.2 release, I'd suggest you upgrade to 1.2 and try again. --Chouserhttp://joyofclojure.com/ -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Problem installing slime
Thank you! I'll check it out. On Sep 12, 9:03 pm, Phil Hagelberg p...@hagelb.org wrote: On Sat, Sep 11, 2010 at 7:55 PM, Oskar oskar.kv...@gmail.com wrote: I am trying to set up clojure for emacs. I use ubuntu and gnu emacs 23. I followed this guidehttp://riddell.us/ClojureWithEmacsSlimeSwankOnUbuntu.html Those instructions are a lot more complicated since they have you install everything by hand. If you follow the README for swank-clojure it's much less error-prone: http://github.com/technomancy/swank-clojure/blob/master/README.md -Phil -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: possible bug
OK, I upgraded to 1.3.0-master-SNAPSHOT but I am still getting a bound x and y after running the test-nested-binding function. There must be something else not quite right. for my REPL I am using: ubuntu linux 10.04 java sdk 1.6.0_21 clojure 1.3.0-master-SNAPSHOT clojure-contrib 1.3.0-SNAPSHOT jLine 0.9.95-SNAPSHOT here is a cut/paste of what I did at the repl: --- Clojure 1.3.0-master-SNAPSHOT user= (load-file TestBinding.clj) #'user/test-nested-binding user= (test-binding) [0 1 2 3 4 5 6 40 80 19 72 31 73 40 61 99 25 13 14 91 81 22 94 87 25 33 11 60 3 6 14 13 77 94 77 83 16 88 38 7 59 79 74 5 98 57 95 90 86 14 64 63 2 34 52 30 86 72 14 25 7 54 83 53 86 66 57 86 55 52 97 8 20 3 21 7 6 66 73 48 16 43 3 43 91 42 21 49 95 25 31 71 4 21 18 78 79 1 57 55 76 42 82 99 49 54 41 3 34 27 26 65 33 37 68 18 88 64 23 81 13 99 55 14 94 61 35 36 32 54 97 26 34 8 26 60 7 97 38 18 84 24 74 57 95 67 4 18 25 75 42 21 75 87 21 94 82 64 80 56 28 34 88 42 3 13 20 28 97 87 68 76 46 33 38 33 22 9 97 37 63 26 13 9 55 52 91 55 74 12 99 69 4 96 0 9 54 60 41 82 4 0 99 24 38 30 74] Random Exception after count = 199 nil user= x IllegalStateException Var user/x is unbound. clojure.lang.Var.deref (Var.java:142) user= (test-nested-binding) [0 1 2 3 4 5 6 52 76 96 80 15 52 35 56 66 78 59 72 36 80 59 52 15 56 65 92 41 68 59 64 42 40 77 78 95 34 51 28 23 99 40 45 2 82 21 11 6 52 28 28 98 19 76 90 79 87 65 71 35 19 29 1 52 96 94 51 49 69 24 54 76 87 88 52 48 64 56 71 64 72 86 22 37 63 10 85 20] Random Exception after count = 80 nil user= x [0 1 2 3 4 5 6 52 76 96 80 15 52 35 56 66 78 59 72 36 80 59 52 15 56 65 92 41 68 59 64 42 40 77 78 95 34 51 28 23 99 40 45 2 82 21 11 6 52 28 28 98 19 76 90 79 87 65 71 35 19 29 1 52 96 94 51 49 69 24 54 76 87 88 52 48 64 56 71 64 72 86 22 37 63 10 85 20] user= (clojure-version) 1.3.0-master-SNAPSHOT user= --- (I also ran this with just a plain clojure repl (no contrib or jline jars in the classpath)) thanks for any help take care, Mike On Sep 13, 11:37 am, doc mdpendergr...@gmail.com wrote: it was on 1.2.0-master but I will upgrade to 1.3.0-master thanks! :-) On Sep 13, 3:01 am, Chouser chou...@gmail.com wrote: On Sun, Sep 12, 2010 at 3:58 PM, doc mdpendergr...@gmail.com wrote: Hello, I am relatively new to clojure and lispy languages in general. I wrote a small program that manipulated thread vars using the binding macro and I am seeing what seems to be strange behavior. To illustrate, here is another small program that reproduces what I am seeing (without all the distraction of the original). There is a reason for the nested bindings in the original code where it seems a bit contrived here. Regardless, if it is something I am doing wrong, please let me know. (declare x y) (def rnd1 (java.util.Random.)) (def rnd2 (java.util.Random.)) (defn throw-random-exception [c] (let [value (.nextInt rnd1 100)] (if (= value 50) (throw (Exception. (str Random Exception after count = c)) (defn change-value-of-thread-local-var [] (set! x (conj x (.nextInt rnd2 100 (defn test-binding [] (binding [x [0 1 2 3 4 5 6]] (try (loop [c 0] (do (change-value-of-thread-local-var) (throw-random-exception c)) (recur (inc c))) (catch Exception e (println (str x \n (.getMessage e))) (defn test-nested-binding [] (binding [x [0 1 2 3 4 5 6]] (try (loop [c 0] (binding [y [7 8 9]] (do (change-value-of-thread-local-var) (throw-random-exception c)) (recur (inc c (catch Exception e (println (str x \n (.getMessage e))) If I load this as a file at the REPL and then run (test-binding) the value of x is unbound when the function returns. However if you run (test-nested-binding) then the value of BOTH x and y have a bound value when the function returns. Is this a bug? If so, where do I report it? If not, what am I doing wrong? I have also moved the binding of x inside the try and it has the same behavior. For me, x and y are unbound after running either function on a recent master branch of Clojure. What version of Clojure are you using? user= (clojure-version) 1.3.0-master-SNAPSHOT If you're using something earlier than the 1.2 release, I'd suggest you upgrade to 1.2 and try again. --Chouserhttp://joyofclojure.com/ -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en