Re: Confusion on Clojure 1.0, compatible clojure-contrib, git-hub, svn, ...
2009/7/13 Cosmin Stejerean : > On Mon, Jul 6, 2009 at 2:59 PM, Laurent PETIT > wrote: >> >> I think there could be a way to make both parts happy : rather than >> just adding the info that it is an old repo in some README file in the >> root directory of the svn repo, committing also an svn delete command >> on all the contents of trunk could help clarify this : by default, >> users checking (or updating !) trunk would have an empty working copy >> as a result (and also just the informative README file). >> But tags would still be there, and also the entire repository history, >> as a svn delete is just deleting files in the commited revision, not >> deleting the history (one could retrieve a working copy by just >> emitting svn up -r N-1 where N would be the "deletion" commit. > > +1 on a comitting a delete of everything and adding a README file saying the > repo has moved. We've had plenty of confusion when switching from SF with > people running old code, and now that there are 2 repos around that are no > longer maintained I suspect the confusion will only increase. +1 -- Michael Wood --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Why this macro fails??
2009/7/14 Stephen C. Gilardi : > > On Jul 13, 2009, at 10:26 PM, sailormoo...@gmail.com wrote: > >> user=> (try (Integer/parseInt "x") (catch Exception _ 0)) >> 0 >> user=> (defmacro parse-int [a default] `(try (Integer/parseInt ~a) >> (catch Except >> ion _ ~default))) >> #'user/parse-int >> user=> (parse-int "x" 0) >> java.lang.Exception: Can't bind qualified name:user/_ (NO_SOURCE_FILE: >> 0) > > You've introduced the name _ to hold the ignored exception. Non-local names > are "resolved" to symbols that include a namespace part: they're interpreted > as references to vars rather than as locals. > > To introduce a local name, you need to use gensym to generate a unique > symbol to name the local. Alternatively, you cause the "# suffix" syntax to > request an "auto-gensym". > > This works: > > user=> (defmacro parse-int [a default] > `(try (Integer/parseInt ~a) > (catch Exception _# ~default))) > #'user/parse-int > user=> (parse-int "123" 4) > 123 > user=> (parse-int "x" 4) > 4 > user=> (macroexpand '(parse-int "123" 4)) > (try (Integer/parseInt "123") > (catch java.lang.Exception ___108__auto__ 4)) > user=> But, of course, there's no need for a macro here: user=> (defn parse-int [a default] (try (Integer/parseInt a) (catch Exception _ default))) #'user/parse-int user=> (parse-int "x" 0) 0 -- Michael Wood --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure 1.0.0 has been uploaded to Maven Central - Finally
Hi, Am 13.07.2009 um 19:12 schrieb Stefan Hübner: just a quick update on the Maven bundle: it has finally been uploaded and is available for your Maven based projects as org.clojure:clojure:1.0.0:jar (groupId, artifactId, version, type). This means that it is also avalaible for Ivy users. So I will remove the clojure artifacts from the kotka.de repository. Note: you don't have to change anything! The organisation and the module names are the same as well as the revision. I will simply remove the mapping to the kotka.de repo from the ivysettings.xml file. So the transition should be smooth without any change on your side. Sincerely Meikel smime.p7s Description: S/MIME cryptographic signature
Re: Why do Enlive template functions return a seq instead of a str?
On Mon, Jul 13, 2009 at 11:26 AM, Robert Campbell wrote: > > I need the _exact_ functionality of the "sniptest" function (which > appears to have been removed) in production code. sniptest lives now in http://github.com/cgrand/enlive/blob/master/test/net/cgrand/enlive_html/test.clj I may have been over-zealous when I moved test-related functions into separate files. > I am trying to > create a decorator in compojure that will accept a response body and > modify the styling in various ways. I can just use the old sniptest > definition: > > (apply str (emit* ((transformation [:h1] (content "hey")) (html-src > (:body response) > > but is there a better way? I'm also not sure what emit* does exactly. emit* serialize one or several trees to a seq of strings. Christophe -- Professional: http://cgrand.net/ (fr) On Clojure: http://clj-me.blogspot.com/ (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: Problem with running clojure on java.
Arghhh...this was causing me a lot of pain. Thanks for the reply. On Jul 13, 11:54 pm, Richard Newman wrote: > Manoj, > > require is for Clojure libraries only. > > You probably want import: > > http://clojure.org/api#toc297 > > but note that you don't need to *load* Java libraries per se, so long > as they're in the classpath: import simply makes the names available > in the current namespace. > > You can see this for yourself: > > $ java -jar /opt/clojure/clojure.jar > Clojure 1.1.0-alpha-SNAPSHOT > user=> (ancestors java.util.Calendar) > #{java.lang.Object java.lang.Cloneable java.lang.Comparable > java.io.Serializable} > user=> (import 'java.util.Calendar) > java.util.Calendar > user=> (= Calendar java.util.Calendar) > true > > No loading necessary; indeed, no classpath fiddling for Calendar, > which is a standard Java class. > > -R --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
clojure.test - Test fixtures and ordering
Hi group, I recently noticed that fixtures were not being called for some tests in my code and it turns out (thanks, Chouser) the use of test-ns-hook is incompatible with fixtures. This isn't necessarily undesirable behavior, but it raises an issue: does anyone want high-level support for grouping and ordering tests while using fixtures to setup and tear down test resources? Currently, if one wishes to specify which tests are called while using fixtures, a test-ns-hook function needs to be implemented that directly calls fixtures with the appropriate tests as arguments. The test namespace that brought the issue to my attention can be found at: http://github.com/mattrepl/clojure-cassandra/blob/ff4ed1c03fb5e9888419198eb8f3a57c7d69beac/src/cassandra/test.clj In this example, the test-ns-hook would become: http://gist.github.com/146934 -Matt --~--~-~--~~~---~--~~ You 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.0.0 has been uploaded to Maven Central - Finally
Stefan, Meikel, Thanks much for this. It looks very interesting. Forgive a newb question but I just downloaded Maven for the first time 30 minutes ago. I read the "Maven in 5 minutes" doc, and executed: mvn archetype:create -DgroupId=org.clojure -DartifactId=clojure followed by: mvn package All the tests passed. I then ran: java -cp clojure-1.0-SNAPSHOT.jar org.clojure.App and got "Hello World" as the output. My expectation is that one of the first two commands would go to a central repository and download a POM file based on the id parameter, which would in turn supply the data necessary to download the other dependencies necessary to build a complete set of clojure files. However, I'm just getting the 2,092 byte clojure jar file. What am I missing? Thanks in advance for any help. --~--~-~--~~~---~--~~ You 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: Can anyone help getting Enclojure to work?
Bruce, There is a Google group for Enclojure at: http://groups.google.com/group/enclojure/ You might try there, as they have discussed similar issues recently. On Jul 13, 6:49 pm, bruceq wrote: > I am having problems getting Enclojure to work properly on Netbeans > 6.7 and also trying 6.5 > > Project REPL seems to work fine. > > Most commands such as evaluate expression throw like this. > > java.lang.NullPointerException > at org.enclojure.ide.navigator.token_nav > $get_namespace_node__408.invoke(token_nav.clj:171) > at org.enclojure.ide.nb.actions.action_handler > $load_file_action__1401.invoke(action_handler.clj:73) > at clojure.lang.Var.invoke(Var.java:346) > at org.enclojure.ide.nb.actions.LoadFile.performAction(LoadFile.java: > 41) > at org.openide.util.actions.NodeAction$DelegateAction$1.run > (NodeAction.java:589) > at org.netbeans.modules.openide.util.ActionsBridge.doPerformAction > (ActionsBridge.java:77) > > Thanks for any help, > Bruce Q Hammond --~--~-~--~~~---~--~~ You 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.0.0 has been uploaded to Maven Central - Finally
Hi there, AlamedaMike wrote: > Stefan, Meikel, > > Thanks much for this. It looks very interesting. > > Forgive a newb question but I just downloaded Maven for the first time > 30 minutes ago. I read the "Maven in 5 minutes" doc, and executed: > > mvn archetype:create -DgroupId=org.clojure -DartifactId=clojure This step doesn't actually specify that you are creating a Clojure project. The groupId and artifactId here are names used in the project you are creating (typically they would be your own package namespace and the name of your project respectively). As you have not specified the type of archetype, Maven has used the default "maven-archetype-quickstart", which creates a trivial Java project. I'm not aware of any archetype for creating a Clojure project. > followed by: > > mvn package > > All the tests passed. I then ran: > > java -cp clojure-1.0-SNAPSHOT.jar org.clojure.App > > and got "Hello World" as the output. > > My expectation is that one of the first two commands would go to a > central repository and download a POM file based on the id parameter, > which would in turn supply the data necessary to download the other > dependencies necessary to build a complete set of clojure files. > However, I'm just getting the 2,092 byte clojure jar file. What am I > missing? The clojure.jar file you have built here contains the trivial "Hello, World" Maven quickstart Java application. It does not relate to Clojure at all, that is just the name you have given it. Out of the box, Maven actually has no support for Clojure. However, at this point, where you are just starting out with Maven (and when you might not actually need to explicitly compile your Clojure), it might be better to just leverage the dependency management by using the Maven Ant tasks from an Ant build, or use Ivy+Ant to grab the dependencies from the Maven repository. That is, just use Maven or Ivy to grab the latest Clojure jar files and use the default on the fly compilation for your Clojure code. If you do need to compile your Clojure code ahead-of-time (AOT), you will need a Maven plugin like: http://github.com/talios/clojure-maven-plugin/tree/master I've not used this plugin but it appears to be in the early stages. There is also: http://github.com/dysinger/clojure-pom/tree/master which appears to use the Maven antrun plugin to call the Clojure compiler, rather than implementing a full-blown Maven plugin. Hope that helps, Jason -- Pulse - Continuous Integration made easy. Does your project have a pulse? Try it free at: http://zutubi.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: clojure.test - Test fixtures and ordering
On Jul 14, 9:41 am, Matt Revelle wrote: > I recently noticed that fixtures were not being called for some tests > in my code and it turns out (thanks, Chouser) the use of test-ns-hook > is incompatible with fixtures. This isn't necessarily undesirable > behavior, but it raises an issue: does anyone want high-level support > for grouping and ordering tests while using fixtures to setup and tear > down test resources? Hi Matt, You're right; it doesn't work. Fixtures were added later, long after test-ns-hook, and I never used them together. Something I've been meaning to do is replace "test-ns-hook" with metadata on the namespace. But that still won't solve the fixture problem. Namespace-wide fixtures ("once-fixtures") are easy -- they should just run around the top-level test function. That's something I can fix, and it will be sufficient for your example. But per-test fixtures ("each-fixtures") present a problem. If the fixtures are run around every test function, then they will be called multiple times when test functions are nested. Should they be called just around the top-level test functions, or just around the bottom- level test functions? And how do you determine where the "bottom" of the test function hierarchy is? I don't know the answers to these questions. So for now, my solution is: if you want to compose tests by calling them as functions, then you should implement your own fixtures using macros, like this: (defmacro with-db [& body] `(... set-up ... ~...@body ... tear-down ...))) (deftest foo (with-db ...)) That way you can decide exactly where the fixture should be run. This is how I used to do fixtures before implementing them in the testing library. -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 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.0.0 has been uploaded to Maven Central - Finally
On Tue, 2009-07-14 at 06:58 -0700, AlamedaMike wrote: > Stefan, Meikel, > > Thanks much for this. It looks very interesting. > > Forgive a newb question but I just downloaded Maven for the first time > 30 minutes ago. I read the "Maven in 5 minutes" doc, and executed: > > mvn archetype:create -DgroupId=org.clojure -DartifactId=clojure > > followed by: > > mvn package > > All the tests passed. I then ran: > > java -cp clojure-1.0-SNAPSHOT.jar org.clojure.App > > and got "Hello World" as the output. > > My expectation is that one of the first two commands would go to a > central repository and download a POM file based on the id parameter, > which would in turn supply the data necessary to download the other > dependencies necessary to build a complete set of clojure files. > However, I'm just getting the 2,092 byte clojure jar file. What am I > missing? > > Thanks in advance for any help. As far as I'm aware, there is no archetype for Clojure projects just yet. I tried making one, but my maven-fu is not quite up to snuff yet. So, unless/until someone creates one and lets us know about it, you have to set up the initial layout of the project manually. What clojure being in the repository means is we can now specify a dependency on clojure 1.0 and have maven automatically download it for us. You will still have to install:install-file on clojure-contrib yourself or find a repository that is hosting a version for you, but you will only have to do that once per machine and that will be shared amongst your projects. I believe what you were doing was creating a new stub java project which was overwriting (in your local repository) the clojure dependency. You will want to replace the groupId and artifactId with your own namespace and project name respectively, and then insert into the dependencies section this: org.clojure clojure 1.0.0 You also might want to look into the clojure-maven-plugin[1] if you are planning on doing AOT compilation of your clojure projects. [1]: git://github.com/talios/clojure-maven-plugin.git Daniel E. Renfer --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Clojure Session Questions
Seems like every time I do a Clojure talk I get questions I can't answer. I did an informal session last night for Portland's Functional Programming Study Group. Two questions came up: First, a Haskell coder made the broad claim that other attempts at STM did not use MVCC because it was "too slow". I responded to the effect that Clojure HashMap's are really fast and fast to mutate (he countered with Haskell being able to modify an unmodifiable map in place if there's only one reference to it). I also emphasized that Rich is very concerned with performance and that if Clojure STM would be implemented some other way if MVCC wasn't fast enough. In retrospect, the right answer may have been more to the effect that Clojure STM limits the number of mutable "slots" (the refs) to keep it efficient. What's the correct response here? Secondly, I told the story about the big simulation on the Azul, and the 20 gig of GC/sec, etc. So if you've coded your simulation really well, do 600 cores give you a 600x speedup over a single core? (Of course not). Given that 10% of the cores are doing GC, how much benefit to you get from spreading across multiple cores? And how much better (or worse) is Clojure at this than a typical, non-naive, Java approach? -- Howard M. Lewis Ship Creator of Apache Tapestry Director of Open Source Technology at Formos --~--~-~--~~~---~--~~ You 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 -~--~~~~--~~--~--~---
VimClojureBox
Hi, I've been thinking about creating something like Clojure Box for Windows Vim users, using Meikel's wonderful VimClojure. The first question is, does anyone think this would be worth while? Assuming the answer is yes... I'm trying to decide if it makes sense to pack everything into a single installer, or if I should assume Vim is already installed. Here are the options I've been considering. 1. Install Clojure, Clojure Contrib, Vim, and VimClojure all under the single umbrella of VimClojureBox. They would all exist in C:\Program Files\VimClojureBox. All jars would be installed to C:\Program Files\VimClojureBox\jars. clj.bat and ng-server.bat would be installed to C:\Program Files\VimClojureBox\bin. Vim would be installed to C:\Program Files\VimClojureBox\vim. The VimClojure plugin and _vimrc file would be installed in the global location as opposed to the user's home directory. Start > VimClojureBox would have entries for starting up Vim, Clojure REPL (clj.bat) and Nailgun Server (ng-server.bat). Context menus for editing in Vim would be added as well. 2. Require that Vim is already installed. Install Clojure, Clojure Contrib, VimClojure .jar and .bat files to same locations as above. Install VimClojure plugin and _vimrc file either to the Vim installation global location or to the user's home directory, gracefully handling existing _vimrc and vimfiles. Start > VimClojureBox entries for starting up Clojure REPL and Nailgun Server. Does anyone have any thoughts on this? Any suggestions? Thanks, Justin --~--~-~--~~~---~--~~ You 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.0.0 has been uploaded to Maven Central - Finally
Jason, Daniel, Thanks for the input. Most helpful. I used the POM at http://github.com/dysinger/clojure-pom/tree/master and was able to build and test clojure and clojure-contrib from the sources there. He also has some good documentation. Recommended. I was hoping not to have to dig to deeply into Maven now, but it looks like I'll have to bite the bullet. Thanks again. On Jul 14, 9:15 am, "Daniel E. Renfer" wrote: > On Tue, 2009-07-14 at 06:58 -0700, AlamedaMike wrote: > > Stefan, Meikel, > > > Thanks much for this. It looks very interesting. > > > Forgive a newb question but I just downloaded Maven for the first time > > 30 minutes ago. I read the "Maven in 5 minutes" doc, and executed: > > > mvn archetype:create -DgroupId=org.clojure -DartifactId=clojure > > > followed by: > > > mvn package > > > All the tests passed. I then ran: > > > java -cp clojure-1.0-SNAPSHOT.jar org.clojure.App > > > and got "Hello World" as the output. > > > My expectation is that one of the first two commands would go to a > > central repository and download a POM file based on the id parameter, > > which would in turn supply the data necessary to download the other > > dependencies necessary to build a complete set of clojure files. > > However, I'm just getting the 2,092 byte clojure jar file. What am I > > missing? > > > Thanks in advance for any help. > > As far as I'm aware, there is no archetype for Clojure projects just > yet. I tried making one, but my maven-fu is not quite up to snuff yet. > > So, unless/until someone creates one and lets us know about it, you have > to set up the initial layout of the project manually. > > What clojure being in the repository means is we can now specify a > dependency on clojure 1.0 and have maven automatically download it for > us. You will still have to install:install-file on clojure-contrib > yourself or find a repository that is hosting a version for you, but you > will only have to do that once per machine and that will be shared > amongst your projects. > > I believe what you were doing was creating a new stub java project which > was overwriting (in your local repository) the clojure dependency. You > will want to replace the groupId and artifactId with your own namespace > and project name respectively, and then insert into the dependencies > section this: > > > org.clojure > clojure > 1.0.0 > > > You also might want to look into the clojure-maven-plugin[1] if you are > planning on doing AOT compilation of your clojure projects. > > [1]: git://github.com/talios/clojure-maven-plugin.git > > Daniel E. Renfer --~--~-~--~~~---~--~~ You 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: VimClojureBox
Hi Justin, Am 14.07.2009 um 18:25 schrieb Justin Johnson: Does anyone have any thoughts on this? Any suggestions? A request for such a "VimClojureBox" came up several times. In fact I set up a "ClojureBall" on bitbucket, but never came far. For your options: maybe number 2? That would allow, that a Windows Installer, a Mac Installer and some unix thing, could be put into the same project (VimClojure itself?). That would take away a lot of required syncronisation: Vim upstream, VC upstream, ... What do you think? Sincerely Meikel PS: You are invited to bring such discussions also to the vimclojure google group if they are specific for VimClojure. General questions can (and should) still be discussed here, of course. smime.p7s Description: S/MIME cryptographic signature
Re: clojure.test - Test fixtures and ordering
On Jul 14, 6:58 pm, Stuart Sierra wrote: > Namespace-wide fixtures ("once-fixtures") are easy -- they should just > run around the top-level test function. That's something I can fix, > and it will be sufficient for your example. > > But per-test fixtures ("each-fixtures") present a problem. If the > fixtures are run around every test function, then they will be called > multiple times when test functions are nested. Should they be called > just around the top-level test functions, or just around the bottom- > level test functions? And how do you determine where the "bottom" of > the test function hierarchy is? I don't think ns-test-hook should really care about this. Perhaps it would be best to consider test-ns-hook a low-level construct that can do whatever it wants with the defined tests and fixtures, and provide some other means for specifying which tests will be run. Alternatively (or additionally), provide a facility for tagging tests and defining fixtures that are run around tests with a specific tag. Then, you could simply use a tag that has no fixtures defined: ; no explicit tag implies "each"? (deftest test1 ...) (deftest test2 ...) (deftest testgroup {:fixtures 'no-fixtures} (test1) (test2)) To get the fixtures called, though, deftest probably needs to return something like: (def testname (fn [] (execute-test test-info-map; we should have the map at this point so we can form a closure, right? (fn [] (actual-test-content-here))) where execute-test would by default be bound to a function that runs whatever fixtures the test has. A custom test-ns-hook could rebind execute-test at will. This could all be done with fixture macros manually too of course, but wrapping functions are probably somewhat easier to write. -- Jarkko PS. For whatever reason, this stuff makes me think of monads. :) --~--~-~--~~~---~--~~ You 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 Session Questions
On Jul 14, 12:24 pm, Howard Lewis Ship wrote: > Seems like every time I do a Clojure talk I get questions I can't > answer. I did an informal session last night for Portland's > Functional Programming Study Group. > > Two questions came up: > > First, a Haskell coder made the broad claim that other attempts at STM > did not use MVCC because it was "too slow". I responded to the effect > that Clojure HashMap's are really fast and fast to mutate (he > countered with Haskell being able to modify an unmodifiable map in > place if there's only one reference to it). I also emphasized that > Rich is very concerned with performance and that if Clojure STM would > be implemented some other way if MVCC wasn't fast enough. > > In retrospect, the right answer may have been more to the effect that > Clojure STM limits the number of mutable "slots" (the refs) to keep it > efficient. What's the correct response here? > The correct response is that most general statements about STM are not very useful. There are tremendous variations in approach and implementation details etc. Clojure's STM does no read tracking, and no transaction tracking. Clojure's MVCC history is adaptive. Were all these true for the others? Clojure does encourage placing immutable values in refs, and thus uses a coarser granularity than STMs that wrap every field access. Nothing about this in in conflict with how you might use an STM in Haskell btw, but is pretty different from most other STMs you'll see for Java, i.e. that let you continue to mutate subfields of objects. In those STMs there is no way to see a consistent object value except inside a transaction and through the STM layer. In Clojure, objects are always values and refs are just time-management tools. Ditto coarse-grained use of STM in Haskell. Really, the bigger contrast is between FP+STM and OO+STM. I'm extremely skeptical of "modify an unmodifiable map in place if there's only one reference to it" working well at all in a true multithreaded context with any potential persistent use. Normal Haskell data structures used shared structure just like Clojure's and provide the same benefits, both inside and out of STM. You'll note I am not criticizing Haskell's STM - it is a very nice design and a good fit for Haskell. Anyone who's happy with Haskell should stick with it. Haskell and Clojure users should just be happy they have STMs and persistent data structures at hand. > Secondly, I told the story about the big simulation on the Azul, and > the 20 gig of GC/sec, etc. So if you've coded your simulation really > well, do 600 cores give you a 600x speedup over a single core? (Of > course not). Given that 10% of the cores are doing GC, how much > benefit to you get from spreading across multiple cores? And how much > better (or worse) is Clojure at this than a typical, non-naive, Java > approach? > There are few general answers to such questions that hold across anything other than a single scenario. Every application has differing degrees of transaction footprint overlap, and transaction durations. Applications with minimal conflicts will get the most benefit from multicore, applications with a lot of overlap will get the least. This is true no matter what conflict avoidance strategy you use (locks, STM, actors). Share less and mutate less, scale more. People also need to be cognizant of the difference between using multicore for parallelization (get one job done faster), and for concurrency (get more jobs done). Both ants demos are designed to demonstrate how to do something potentially hard (many jobs, with arbitrarily overlapping resource usage), correctly and easily. There are higher constant-factor costs for accessing an STM-managed reference than a field, so a single lock covering a lot of field accesses has a better per field overhead story. Clojure sits in a good spot with its coarser granularity - you only pay once to pull the whole immutable object out of the ref, then you can have at it without any STM code in the path. Everyone who is genuinely interested in STM should try one on their own problems and provide feedback. These theoretical discussions are just that, theoretical. I could argue all day about why I think MVCC STM with adaptive history, plus immutable persistent data structures, used in a coarse-grained manner, is a good approach. Instead, I built it, and everyone can try it. Rich --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Clojure emacs formatting of letfn
I'm using Clojure Box on Windows, corresponding to version 1.0. I'm unhappy with the way it formats the letfn special form. It doesn't seem to know that this form is used for defining functions, so the formatting doesn't look anything at all like a function definition. Any suggestions on how to add more sane indenting for this form? Thanks. --~--~-~--~~~---~--~~ You 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: surprising behaviour with do, ns and def
Hi Stuart Thanks for the explanation, that makes sense and I very much doubt I'd have figured that out by myself without a lot of head scratching. And you were right about the intern function, that does exactly what I was looking for. Cheers Chris On Jul 14, 3:04 am, Stuart Sierra wrote: > On Jul 13, 3:58 pm, Chris Kent wrote: > > > user=> (ns a) (def foo "foo") > > a=> #'a/foo > > a=> > > > If the same code is executed inside a do form the var is defined in > > the original namespace. I thought that the do should make no > > difference. Is this the intended behaviour? > > > user=> (do (ns a) (def foo "foo")) > > #'user/foo > > a=> > > Hi Chris, > > This involves some subtle details of how the Clojure Reader works, but > I'll try to explain what's going on. > > In your first example, the Reader reads the (ns...) form first, then > evaluates it, which sets the current namespace to "a". Then the > Reader reads the (def...) form, while it is in namespace "a". So, to > emphasize, we are in namespace "a" when the (def...) form is READ. > > In your second example, the Reader reads the entire (do...) form > before anything gets evaluated. At that time, we are still in the > "user" namespace. So the (def...) form gets READ in namespace "user". > > The crux is this: (def...) is a special form, so the usual rules don't > apply. In this case, what matters is when the (def...) form gets > READ, not when it gets evaluated. To get the behavior you expect, try > the "intern" function. > > -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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: ANN: FnParse, a functional parsing library
Looks quite nice, can you tell how it compares (performance wise) to other parsing libraries? On Jul 6, 3:55 am, Wilson MacGyver wrote: > Thanks for the tip on looking at clojure.contrib. I keep forgetting to > check there. > > On Jul 5, 2009, at 4:20 PM, samppi wrote: > > > > > If you need a JSON parser, there's already a good one included with > > clojure.contrib. The one with the FnParse library is just a sample to > > show how it works. But please feel free to use it however it can be > > useful to you. :) > > > On Jul 4, 1:45 pm, Wilson MacGyver wrote: > >> Very timely, I need to parse a bunch on JSON files on Monday :) good > >> work > > >> Sent from my iPhone > > >> On Jul 4, 2009, at 3:16 PM, samppi wrote: > > >>> I'm pleased to announce FnParse, a monadic functional parsing > >>> library > >>> for Clojure, half a year in the making. I started on FnParse in > >>> December as my first Clojure project, and now it has matured to > >>> something that I believe is very and immediately useful. Currently, > >>> I'm writing a YAML parser using FnParse. > > >>> With FnParse, you can easily parse a string or any sequence of > >>> tokens > >>> into native data structures. FnParse is based on the concept of the > >>> rule, a self-contained function that accepts a state data structure, > >>> containing a sequence of tokens, and either consumes some tokens-- > >>> turning them into new data--or fails. Rules correspond nicely to > >>> EBNF > >>> productions and productions in other sort of grammars. FnParse > >>> provides common rules, functions that create new rules, and > >>> functions > >>> that facilitate using rules. > > >>> A sample JSON parser is athttp://wiki.github.com/joshua-choi/ > >>> fnparse/sample-json-parser > >>> . > >>> Online documentation is available at:http://wiki.github.com/joshua- > >>> choi/fnparse > >>> . > >>> The source is at:http://github.com/joshua-choi/fnparse. > > >>> If you are confused about anything or find any bugs, please create > >>> an > >>> issue on GitHub (http://github.com/joshua-choi/fnparse/issues) or > >>> send > >>> me a message on GitHub. --~--~-~--~~~---~--~~ You 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 -~--~~~~--~~--~--~---
easiest JMX API ever, in Clojure...
...wants your help to be born! :-) There is a branch in clojure-contrib that includes work so far: http://github.com/richhickey/clojure-contrib/tree/jmx . I want feedback on ease of use, most important features to add next, code quality, you name it. Here's a teaser: - Usage (require '[clojure.contrib.jmx :as jmx]) - What beans do I have? (jmx/mbean-names "*:*") -> # (:Verbose :ObjectPendingFinalizationCount :HeapMemoryUsage :NonHeapMemoryUsage) - What is the value of an attribute? (jmx/read "java.lang:type=Memory" :ObjectPendingFinalizationCount) -> 0 - Can't I just have *all* the attributes in a Clojure map? (jmx/mbean "java.lang:type=Memory") -> {:NonHeapMemoryUsage {:used 16674024, :max 138412032, :init 24317952, :committed 24317952}, :HeapMemoryUsage {:used 18619064, :max 85393408, :init 0, :committed 83230720}, :ObjectPendingFinalizationCount 0, :Verbose false} - Can I find and invoke an operation? (jmx/operation-names "java.lang:type=Memory") -> (:gc) (jmx/invoke "java.lang:type=Memory" :gc) -> nil - What about some other process? Just run *any* of the above code inside the with-connection form: (jmx/with-connection {:host "localhost", :port 3000} (jmx/mbean "java.lang:type=Memory")) -> {:ObjectPendingFinalizationCount 0, :HeapMemoryUsage ... etc.} --~--~-~--~~~---~--~~ You 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: binding issue
Ok, so *if* this is intended behavior, what have people been doing to bind variables dependant on other bindings? I can't be the first to run into this. Thanks! Brandon On Jul 12, 12:05 am, Tom Faulhaber wrote: > Looking at the clojure docs, it doesn't appear to be defined whether > binding is a parallel (all vars are computed based on the initial > state) or sequential (vars are computed using the new values for vars > used in the same binding vector). A quick test shows that it appears > to be parallel: > > (binding [a 1 b a] [a b]) => [1 nil] > > Reviewing the implementation in clojure.contrib makes it seem that is > indeed true. It looks like all of the new values for the binding forms > are computed before the pairs are added to a hash that is sent to > pushThreadBindings. > > Whether this is the desired behavior is another question entirely. > > In any case, the fact that it is not documented seems like a bug, > especially since this behavior is different from let (as you point > out). > > Tom > > On Jul 11, 9:01 pm, bgray wrote: > > > > > Is this behavior expected from binding? > > > user=> (def a nil) > > #'user/a > > user=> (def b nil) > > #'user/b > > user=> (binding [a 1 b (+ a 1)] a) > > java.lang.NullPointerException (NO_SOURCE_FILE:0) > > user=> (binding [a 1 b (+ a 1)] b) > > java.lang.NullPointerException (NO_SOURCE_FILE:0) > > user=> (let [a 1 b (+ a 1)] a) > > 1 > > user=> (let [a 1 b (+ a 1)] b) > > 2 > > > Thanks, > > Brandon- Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ You 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: easiest JMX API ever, in Clojure...
Looks very nice; what are you planning to use JMX for? On Tue, Jul 14, 2009 at 11:23 AM, Stuart Halloway wrote: > > ...wants your help to be born! :-) > > There is a branch in clojure-contrib that includes work so far: > http://github.com/richhickey/clojure-contrib/tree/jmx > . I want feedback on ease of use, most important features to add next, > code quality, you name it. > > Here's a teaser: > > - > Usage > (require '[clojure.contrib.jmx :as jmx]) > > - > What beans do I have? > > (jmx/mbean-names "*:*") > -> # java.lang:type=Memory, ...] > > - > What attributes does a bean have? > > (jmx/attribute-names "java.lang:type=Memory") > -> (:Verbose :ObjectPendingFinalizationCount > :HeapMemoryUsage :NonHeapMemoryUsage) > > - > What is the value of an attribute? > > (jmx/read "java.lang:type=Memory" :ObjectPendingFinalizationCount) > -> 0 > > - > Can't I just have *all* the attributes in a Clojure map? > > (jmx/mbean "java.lang:type=Memory") > -> {:NonHeapMemoryUsage > {:used 16674024, :max 138412032, :init 24317952, :committed > 24317952}, > :HeapMemoryUsage > {:used 18619064, :max 85393408, :init 0, :committed 83230720}, > :ObjectPendingFinalizationCount 0, > :Verbose false} > > - > Can I find and invoke an operation? > > (jmx/operation-names "java.lang:type=Memory") > -> (:gc) > (jmx/invoke "java.lang:type=Memory" :gc) > -> nil > > - > What about some other process? Just run *any* of the above code > inside the with-connection form: > > (jmx/with-connection {:host "localhost", :port 3000} > (jmx/mbean "java.lang:type=Memory")) > -> {:ObjectPendingFinalizationCount 0, > :HeapMemoryUsage ... etc.} > > > > > > > > -- Howard M. Lewis Ship Creator of Apache Tapestry Director of Open Source Technology at Formos --~--~-~--~~~---~--~~ You 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 -~--~~~~--~~--~--~---
another binding issue?
I'm not sure if this is a binding issue or not. user=> (def a 1) #'user/a user=> (binding [a 3] (filter #(= % a) '(1 2 3))) (1) user=> In this case, I was expecting a list with 3 in it. Thanks, Brandon --~--~-~--~~~---~--~~ You 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: another binding issue?
On Jul 14, 10:04 pm, bgray wrote: > I'm not sure if this is a binding issue or not. > > user=> (def a 1) > #'user/a > user=> (binding [a 3] (filter #(= % a) '(1 2 3))) > (1) > user=> > > In this case, I was expecting a list with 3 in it. This is a common gotcha. It's actually a laziness issue: the seq produced by filter is realised only after it exits the binding scope, thus producing '(1). You need to use "doall" to force the seq if you want the binding to apply. -- Jarkko --~--~-~--~~~---~--~~ You 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: another binding issue?
On Tue, Jul 14, 2009 at 3:04 PM, bgray wrote: > > I'm not sure if this is a binding issue or not. > > user=> (def a 1) > #'user/a > user=> (binding [a 3] (filter #(= % a) '(1 2 3))) > (1) > user=> > > In this case, I was expecting a list with 3 in it. filter is lazy, and your lazy seq is "leaking" out of the binding dynamic scope. You must be careful with 'binding' in the presence of delayed evaluation and threads. This includes lazy-seqs, delays, futures, agents, and really closures in general. To get your expected result, simply force the seq to be realized before you return it, such as with doall, or put it into a non-lazy collection, such as with vec. user=> (binding [a 3] (doall (filter #(= % a) '(1 2 3 (3) --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 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: another binding issue?
That makes sense. Thanks for the quick help! On Jul 14, 2:40 pm, Chouser wrote: > On Tue, Jul 14, 2009 at 3:04 PM, bgray wrote: > > > I'm not sure if this is a binding issue or not. > > > user=> (def a 1) > > #'user/a > > user=> (binding [a 3] (filter #(= % a) '(1 2 3))) > > (1) > > user=> > > > In this case, I was expecting a list with 3 in it. > > filter is lazy, and your lazy seq is "leaking" out of the > binding dynamic scope. You must be careful with 'binding' > in the presence of delayed evaluation and threads. This > includes lazy-seqs, delays, futures, agents, and really > closures in general. > > To get your expected result, simply force the seq to be > realized before you return it, such as with doall, or put it > into a non-lazy collection, such as with vec. > > user=> (binding [a 3] (doall (filter #(= % a) '(1 2 3 > (3) > > --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 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: another binding issue?
On Tue, Jul 14, 2009 at 12:40 PM, Jarkko Oranen wrote: > This is a common gotcha. It's actually a laziness issue: the seq > produced by filter is realised only after it exits the binding scope, > thus producing '(1). You need to use "doall" to force the seq if you > want the binding to apply. Yeah, but more and more I'm finding that with complex code, it can be rather difficult to identify the parts that are lazy and the parts that aren't. Which makes using binding rather risky. I've started to refactor most of my code to avoid dynamic binding, because I'm tired of getting burned by this gotcha. Which is a shame. --~--~-~--~~~---~--~~ You 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: another binding issue?
I'm a little unclear on why this happens still. #(= % a) is a closure, correct? My understanding is that this should capture the environment when it is defined. Why does "the environment" not include the current bindings? -- Aaron On Tue, Jul 14, 2009 at 4:03 PM, Mark Engelberg wrote: > > On Tue, Jul 14, 2009 at 12:40 PM, Jarkko Oranen wrote: > > This is a common gotcha. It's actually a laziness issue: the seq > > produced by filter is realised only after it exits the binding scope, > > thus producing '(1). You need to use "doall" to force the seq if you > > want the binding to apply. > > Yeah, but more and more I'm finding that with complex code, it can be > rather difficult to identify the parts that are lazy and the parts > that aren't. Which makes using binding rather risky. I've started to > refactor most of my code to avoid dynamic binding, because I'm tired > of getting burned by this gotcha. Which is a shame. > > > > --~--~-~--~~~---~--~~ You 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: another binding issue?
closures capture lexical scope, binding creates dynamic scope. lexical scope is where a closure is defined, dynamic is when it is called. because filter is lazy, the closure is called outside the dynamic scope created by binding On Jul 14, 1:07 pm, Aaron Cohen wrote: > I'm a little unclear on why this happens still. > #(= % a) is a closure, correct? My understanding is that this should > capture the environment when it is defined. Why does "the environment" not > include the current bindings? > > -- Aaron > > On Tue, Jul 14, 2009 at 4:03 PM, Mark Engelberg > wrote: > > > > > > > On Tue, Jul 14, 2009 at 12:40 PM, Jarkko Oranen wrote: > > > This is a common gotcha. It's actually a laziness issue: the seq > > > produced by filter is realised only after it exits the binding scope, > > > thus producing '(1). You need to use "doall" to force the seq if you > > > want the binding to apply. > > > Yeah, but more and more I'm finding that with complex code, it can be > > rather difficult to identify the parts that are lazy and the parts > > that aren't. Which makes using binding rather risky. I've started to > > refactor most of my code to avoid dynamic binding, because I'm tired > > of getting burned by this gotcha. Which is a shame. --~--~-~--~~~---~--~~ You 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: easiest JMX API ever, in Clojure...
2009/7/14 Stuart Halloway : > > ...wants your help to be born! :-) > > There is a branch in clojure-contrib that includes work so far: > http://github.com/richhickey/clojure-contrib/tree/jmx > . I want feedback on ease of use, most important features to add next, > code quality, you name it. > > Here's a teaser: I like it :) It doesn't seem to work with Clojure 1.0: user=> (require '[clojure.contrib.jmx :as jmx]) java.io.FileNotFoundException: Could not locate clojure/stacktrace__init.class or clojure/stacktrace.clj on classpath: (jmx.clj:0) But seems to work fine in the latest snapshot (at least for the local stuff). I've never tried this sort of thing before, but I'm trying to connect to a JBoss instance with it and not having much luck. I think I need to authenticate somehow, but I have no idea how to do that. Normally you look at these settings through a web interface, so I'm not quite sure what's necessary to bypass the web interface. Thanks :) -- Michael Wood --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: binding issue
On Jul 14, 3:01 pm, bgray wrote: > Ok, so *if* this is intended behavior, what have people been doing to > bind variables dependant on other bindings? I can't be the first to > run into this. Just nest multiple binding forms: (binding [a ...] (binding [b ...] ...)) Not pretty, but it does what you want. Alternately, use "let" to set up values sequentially, then bind them all at once. (let [a ..., b ...] (binding [*a* a, *b* b] ...)) -SS --~--~-~--~~~---~--~~ You 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: binding issue
Hi, Am 14.07.2009 um 21:01 schrieb bgray: Ok, so *if* this is intended behavior, what have people been doing to bind variables dependant on other bindings? I can't be the first to run into this. I haven't run into this, but there are two obvious approaches: (let [new-a (compute n e w a)] (binding [a new-a b (inc new-a)] [a b])) (binding [a (comput n e w a)] (binding [b (inc a)] [a b])) I'm not sure it's intended, though. Consistency between the let-like forms and binding would be nice. Sincerely Meikel smime.p7s Description: S/MIME cryptographic signature
Re: clojure.test - Test fixtures and ordering
On Jul 14, 1:23 pm, Jarkko Oranen wrote: > Perhaps it > would be best to consider test-ns-hook a low-level construct that can > do whatever it wants with the defined tests and fixtures, and provide > some other means for specifying which tests will be run. Yes, I'm leaning this way too. If you want to control the order in which tests run, you should also control when set-up / tear-down occurs, and not use the fixture mechanism at all. For example: (defn test-ns-hook ... global set-up ... (test-group-one) (test-group-two) ... global tear-down ...) (deftest test-group-one ... set-up specific to group one ... (test-a) (test-b)) -SS --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Clojure Workshop in London next Monday
Next Monday evening we're hosting a Clojure Workshop at the ThoughtWorks offices in central London. This will be an introductory workshop where I hope that we'll all start to learn Clojure together. I'll present a quick introduction to what's interesting and different about Clojure, then we'll run a coding dojo to explore the language by implementing a simple program together. I'm aiming this event primarily at those who've started dabbling with Clojure or are interested in getting started. You won't need any previous experience with Clojure or any Lisp to get involved, but more experienced hands will be very welcome to guide us through the learning experience. All the info, including sign up link, here http://londongeeknights.wetpaint.com/page/Clojure+Workshop Hope to see some of you there, Alex --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Accessing dynamic and lexical bindings
I'm trying to determine if there is a way to gain access to the dynamic and lexical bindings tables at both run-time and compile- time. In general this seems like a bad idea, but I'd like to be able to modify the evaluation environment while performing compile-time partial evaluation. Last night I played around with clojure.lang.Var/ find and clojure.lang.Namespace.getMappings which appeared to let me access the dynamic scope. I went further, digging into the .java code and found the static field clojure.lang.Compiler/LOCAL_ENV, which if accessed during macro expansion time contains the lexical bindings. I know from experimenting that an exception is thrown if you attempt to evaluate a lexical variable during compilation time (makes sense): (let [x 5] (clojure.contrib.macros/const x)) doesn't work (which makes sense since 5 could be anything). So, is there a way to access the dynamic and lexical bindings directly, at compile time or run time? If not, are there any shortcuts around implementing my own tables and performing substitution? -- 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 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: VimClojureBox
> > For your options: maybe number 2? > > That would allow, that a Windows Installer, a Mac Installer > and some unix thing, could be put into the same project > (VimClojure itself?). That would take away a lot of required > syncronisation: Vim upstream, VC upstream, ... > > What do you think? > That sounds reasonable to me. I would only be able to work on the Windows installer but I'd be willing to collaborate with others to incorporate other installers into the project. I have setup http://github.com/HonestHacker/VimClojureBox/ as a place holder for the project. > > Sincerely > Meikel > > PS: You are invited to bring such discussions also to > the vimclojure google group if they are specific for > VimClojure. General questions can (and should) still > be discussed here, of course. > I didn't notice there was a vimclojure group defined. I've joined it now and will carry on the conversation there. Thanks. Justin --~--~-~--~~~---~--~~ You 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: another binding issue?
It almost seems like what you want is for lazy data structures to close over the dynamic vars that have been modified from their root bindings at the time the lazy data structure is created. Seems like coming up with well-defined semantics for this would be an interesting research problem, and if done properly, could end up matching people's intuition and being a lot more useful than the current awkwardness of the way that vars and laziness interact. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: ANN: FnParse, a functional parsing library
I haven't compared it directly to any other parsing libraries, but I'd surmise that it'll be slower than more optimized libraries, especially Java ones. Currently, the optimizations that the library has is that it lazily evaluates both rules (in the conc and alt forms) and token sequences. At this moment, I'm also working on a memoization rule maker, which hopefully would make parsers work in polynomial time. On Jul 14, 11:21 am, ronen wrote: > Looks quite nice, can you tell how it compares (performance wise) to > other parsing libraries? > > On Jul 6, 3:55 am, Wilson MacGyver wrote: > > > > > Thanks for the tip on looking at clojure.contrib. I keep forgetting to > > check there. > > > On Jul 5, 2009, at 4:20 PM, samppi wrote: > > > > If you need a JSON parser, there's already a good one included with > > > clojure.contrib. The one with the FnParse library is just a sample to > > > show how it works. But please feel free to use it however it can be > > > useful to you. :) > > > > On Jul 4, 1:45 pm, Wilson MacGyver wrote: > > >> Very timely, I need to parse a bunch on JSON files on Monday :) good > > >> work > > > >> Sent from my iPhone > > > >> On Jul 4, 2009, at 3:16 PM, samppi wrote: > > > >>> I'm pleased to announce FnParse, a monadic functional parsing > > >>> library > > >>> for Clojure, half a year in the making. I started on FnParse in > > >>> December as my first Clojure project, and now it has matured to > > >>> something that I believe is very and immediately useful. Currently, > > >>> I'm writing a YAML parser using FnParse. > > > >>> With FnParse, you can easily parse a string or any sequence of > > >>> tokens > > >>> into native data structures. FnParse is based on the concept of the > > >>> rule, a self-contained function that accepts a state data structure, > > >>> containing a sequence of tokens, and either consumes some tokens-- > > >>> turning them into new data--or fails. Rules correspond nicely to > > >>> EBNF > > >>> productions and productions in other sort of grammars. FnParse > > >>> provides common rules, functions that create new rules, and > > >>> functions > > >>> that facilitate using rules. > > > >>> A sample JSON parser is athttp://wiki.github.com/joshua-choi/ > > >>> fnparse/sample-json-parser > > >>> . > > >>> Online documentation is available at:http://wiki.github.com/joshua- > > >>> choi/fnparse > > >>> . > > >>> The source is at:http://github.com/joshua-choi/fnparse. > > > >>> If you are confused about anything or find any bugs, please create > > >>> an > > >>> issue on GitHub (http://github.com/joshua-choi/fnparse/issues) or > > >>> send > > >>> me a message on GitHub. --~--~-~--~~~---~--~~ You 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: another binding issue?
this is how you do it: user=> (def a 0) #'user/a user=> (binding [a 1] (map #(+ % a) (range 5))) (0 1 2 3 4) user=> (binding [a 1] (let [a a] (map #(+ a %) (range 5 (1 2 3 4 5) user=> you capture the dynamic scope in the lexical scope so the closure can close over it. dunno how applicable this is to more complex uses of binding On Tue, Jul 14, 2009 at 6:09 PM, Mark Engelberg wrote: > > It almost seems like what you want is for lazy data structures to > close over the dynamic vars that have been modified from their root > bindings at the time the lazy data structure is created. Seems like > coming up with well-defined semantics for this would be an interesting > research problem, and if done properly, could end up matching people's > intuition and being a lot more useful than the current awkwardness of > the way that vars and laziness interact. > > > > -- And what is good, Phaedrus, And what is not good— Need we ask anyone to tell us these things? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure emacs formatting of letfn
Mark Engelberg writes: > I'm unhappy with the way it formats the letfn special form. It > doesn't seem to know that this form is used for defining functions, so > the formatting doesn't look anything at all like a function > definition. Any suggestions on how to add more sane indenting for > this form? I haven't used letfn; could you give an example of how it's formatted and how you think it should be formatted? -Phil --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure emacs formatting of letfn
On Tue, Jul 14, 2009 at 7:15 PM, Phil Hagelberg wrote: > I haven't used letfn; could you give an example of how it's formatted > and how you think it should be formatted? > > -Phil This is a total nonsense function, just to show formatting (will it even show up in googlegroups with the proper formatting?): (defn test-letfn [n] (letfn [(function1 [a b] (+ (function2 a) sqr-n)) (function2 [a] (* 2 3))] (function1 8 10))) The bracket under the letfn is indented a couple spaces more than I'd probably prefer, but that's not really what bothers me. The bodies of the functions are indented WAY too much. --~--~-~--~~~---~--~~ You 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 emacs formatting of letfn
Mark Engelberg writes: > This is a total nonsense function, just to show formatting (will it > even show up in googlegroups with the proper formatting?): > > (defn test-letfn [n] > (letfn > [(function1 [a b] > (+ (function2 a) sqr-n)) >(function2 [a] > (* 2 3))] > (function1 8 10))) > > The bracket under the letfn is indented a couple spaces more than I'd > probably prefer, but that's not really what bothers me. The bodies of > the functions are indented WAY too much. I see. The way I usually see let-forms is having the argument list start on the same line as the "let" itself, which would look like: > (defn test-letfn [n] > (letfn [(function1 [a b] > (+ (function2 a) sqr-n)) > (function2 [a] > (* 2 3))] >(function1 8 10))) The problem with the function bodies is that the fact that "function1" starts a new function is impossible to determine without looking at the greater context, that being the fact that it's within the binding vector of a letfn. I'm sure it's possible to solve this, but it's rather beyond me. It's unclear (to me at least) what letfn offers you over regular let, since functions are just values anyway: > (let [f2 (fn [a] >(* 2 3)) > f1 (fn [a b] >(+ (f2 a) 99))] > (f1 8 10)) Sure this is a contrived example, but the indentation works fine here since it knows that "fn" means function. Is the only advantage the fact that you can put f1 before f2? -Phil --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure emacs formatting of letfn
> The bracket under the letfn is indented a couple spaces more than I'd > probably prefer, but that's not really what bothers me. The bodies of > the functions are indented WAY too much. Incidentally, VimClojure gets the second part wrong, too (though it gets the first correct). Indenting 4 additional spaces on every line to try to trick Google Groups, the output is: (defn test-letfn [n] (letfn [(function1 [a b] (+ (function2 a) sqr-n)) (function2 [a] (* 2 3))] (function1 8 10))) I think it should be (defn test-letfn [n] (letfn [(function1 [a b] (+ (function2 a) sqr-n)) (function2 [a] (* 2 3))] (function1 8 10))) --~--~-~--~~~---~--~~ You 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 emacs formatting of letfn
> It's unclear (to me at least) what letfn offers you over regular let, > since functions are just values anyway: let has sequential binding; letfn makes the names of each function available in all of them. This allows for mutual recursion, amongst other things. (Presumably there are some compiler tricks available in the future, too -- the compiler knows about arglists, return types, that these are functions, etc. etc.) http://clojure.org/api#toc332 letfn is equivalent to Common Lisp's LABELS. Binding function objects to names in let is equivalent to nested FLETs. --~--~-~--~~~---~--~~ You 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 emacs formatting of letfn
On Tue, Jul 14, 2009 at 7:46 PM, Phil Hagelberg wrote: > I see. The way I usually see let-forms is having the argument list start > on the same line as the "let" itself, which would look like: > >> (defn test-letfn [n] >> (letfn [(function1 [a b] >> (+ (function2 a) sqr-n)) >> (function2 [a] >> (* 2 3))] >> (function1 8 10))) When the function bodies are complex, you really want them to start off as far to the left as possible, which is why I would start the left bracket on the next line. Also, it allows you to put in comment lines explaining what the function does -- another important thing for complex functions.. > It's unclear (to me at least) what letfn offers you over regular let, > since functions are just values anyway: In my silly example, nothing. But if the functions are mutually recursive, you can't do that with let. --~--~-~--~~~---~--~~ You 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: VimClojureBox
i vote for zero config, option 1. On Tue, Jul 14, 2009 at 12:25 PM, Justin Johnson wrote: > Hi, > > I've been thinking about creating something like Clojure Box for Windows > Vim users, using Meikel's wonderful VimClojure. The first question is, does > anyone think this would be worth while? > > Assuming the answer is yes... > > I'm trying to decide if it makes sense to pack everything into a single > installer, or if I should assume Vim is already installed. Here are the > options I've been considering. > > 1. Install Clojure, Clojure Contrib, Vim, and VimClojure all under the > single umbrella of VimClojureBox. They would all exist in C:\Program > Files\VimClojureBox. All jars would be installed to C:\Program > Files\VimClojureBox\jars. clj.bat and ng-server.bat would be installed to > C:\Program Files\VimClojureBox\bin. Vim would be installed to C:\Program > Files\VimClojureBox\vim. The VimClojure plugin and _vimrc file would be > installed in the global location as opposed to the user's home directory. > Start > VimClojureBox would have entries for starting up Vim, Clojure REPL > (clj.bat) and Nailgun Server (ng-server.bat). Context menus for editing in > Vim would be added as well. > > 2. Require that Vim is already installed. Install Clojure, Clojure > Contrib, VimClojure .jar and .bat files to same locations as above. Install > VimClojure plugin and _vimrc file either to the Vim installation global > location or to the user's home directory, gracefully handling existing > _vimrc and vimfiles. Start > VimClojureBox entries for starting up Clojure > REPL and Nailgun Server. > > Does anyone have any thoughts on this? Any suggestions? > > Thanks, > Justin > > > > --~--~-~--~~~---~--~~ You 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.0.0 has been uploaded to Maven Central - Finally
It shouldn't be hard to create a clojure archetype actually, now that clojures in the main repo, if I get a compiled version of my clojure-maven-plugin in a public repository somewhere I could easily make an archetype that combines the two, with a ready to run clojure project. I think I have a new weekend project ;-) -- On Wed, Jul 15, 2009 at 2:47 AM, Jason Sankey wrote: > "maven-archetype-quickstart", which creates a trivial Java project. I'm > not aware of any archetype for creating a Clojure project. --~--~-~--~~~---~--~~ You 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 -~--~~~~--~~--~--~---