Re: clojure.zip and root

2009-07-21 Thread B Smith-Mannschott
On Mon, Jul 20, 2009 at 12:33, kyle smiththe1physic...@gmail.com wrote: At the moment root works like an unzip. What you want it is some kind of up-till-root shortcut. Yep. For now, I've added root-loc to my local copy of clojure, although I second the name unzip. Hmm, though this is

Re: Uncle Bob: bowling meets Clojure

2009-07-21 Thread Mark Triggs
Hi Stu, Stuart Halloway stuart.hallo...@gmail.com writes: Uncle Bob Martin, a very well-respected OO and agile guy, is learning Clojure. He has posted an example [1] and asked for feedback from the Clojure community. I have made my suggestions in code [2] and will be writing them up

sizeof in Clojure

2009-07-21 Thread Jan Rychter
Is there a way to get the size of a data structure in Clojure? I've been wondering how much more space-efficient vectors are than lists, but I don't know how to measure it. --J. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

Re: Emacs clojure mode: how to set current directory classpath

2009-07-21 Thread Baishampayan Ghose
Phil, As long as you unpack your deps all in one place and stick to the same classpath conventions, the fact that you can't change the classpath at runtime is not a significant problem. Can you kindly explain exactly what kind of conventions you follow as far as laying out the code,

Re: Emacs clojure mode: how to set current directory classpath

2009-07-21 Thread Baishampayan Ghose
Phil, As long as you unpack your deps all in one place and stick to the same classpath conventions, the fact that you can't change the classpath at runtime is not a significant problem. Can you kindly explain exactly what kind of conventions you follow as far as laying out the code,

Re: Uncle Bob: bowling meets Clojure

2009-07-21 Thread Stuart Halloway
Very nice! I would change the :satisfies clause for underachievers so that it does not create an ordering dependency. You should post this over on Uncle Bob's site. Stu Hi Stu, Stuart Halloway stuart.hallo...@gmail.com writes: Uncle Bob Martin, a very well-respected OO and agile guy,

Re: Emacs clojure mode: how to set current directory classpath

2009-07-21 Thread Anne Ogborn
While we're on this subject, anybody know the same information for La Clojure? That is, how to set up the current directory and classpath so one can compile java classes from Clojure? IntelliJ has many strengths, but a simple, transparent mechanism to add an arbitrary directory or jar to

Re: Simple data structure access macro

2009-07-21 Thread John Harrop
On Mon, Jul 20, 2009 at 4:31 PM, Moses mosesam...@gmail.com wrote: I come primarily from a perl programming background, but am trying to learn Clojure. I'm looking for a clojure equivalent to the following. Perl: my $nestedDS = [ foo, { hi = there, hello = [buddy] }, hi] my $foo

Re: Clojure as a CGI language?

2009-07-21 Thread Niels Mayer
On Mon, Jul 20, 2009 at 2:01 PM, robert.e.hick...@googlemail.com robert.e.hick...@googlemail.com wrote: I was wondering what the best way of using clojure as a language for writing CGI web applications would be. I know that it can be used for web programming using java web servers, however I

Re: Clojure as a CGI language?

2009-07-21 Thread Daniel
On Tue, Jul 21, 2009 at 10:14 AM, robr.p.l...@gmail.com wrote: It sounds like you want to avoid the approach of Apache Tomcat and Clojure servelets (why not do it that way by the way?)  CGI allows you to operate any program via the web, but it will be alot slower if you have load everything

Re: Simple data structure access macro

2009-07-21 Thread James Sofra
The get-in that ataggart suggested is probably what you want but destructuring can also be used here. (def nested-ds [foo, {:hi there :hello [buddy]}, hi]) (let [[foo {there :hi [buddy] :hello} hi] nested-ds] (print foo there buddy hi)) On Jul 21, 6:31 am, Moses mosesam...@gmail.com wrote:  

Re: Simple data structure access macro

2009-07-21 Thread James Sofra
You can also use destructuring for this: (def nested-ds [foo, {:hi there :hello [buddy]}, hi]) (let [[foo {there :hi [buddy] :hello} hi] nested-ds] (print foo there buddy hi)) James On Jul 21, 6:31 am, Moses mosesam...@gmail.com wrote:   I come primarily from a perl programming background,

Re: Function of clojure.templates

2009-07-21 Thread Tim Snyder
apply-template is used internal to the template namespace by the do- template macro. The do-template macro that allows you to apply some code to groups of arguments. In order to get what I think you're after, use do-template in the following fashion: (do-template (+ _1 _1) 2) -- (+ 2 2) On Jul

Re: Uncle Bob: bowling meets Clojure

2009-07-21 Thread Jim Oly
On Jul 20, 7:01 pm, Mark Engelberg mark.engelb...@gmail.com wrote: Where is the original problem statement? It is hidden in Powerpoint slides (http://butunclebob.com/files/ downloads/Bowling%20Game%20Kata.ppt) linked on the description of the bowling game (http://butunclebob.com/

Re: Function of clojure.templates

2009-07-21 Thread Stuart Sierra
Hi Tim, Samppi, clojure.contrib.template (since renamed clojure.template) has gone through a couple of different forms. Basically, do-template does something similar to map but at compile time. This was necessary for the are macro in clojure.contrib.test- is (since renamed clojure.test). Look

Re: sizeof in Clojure

2009-07-21 Thread Stuart Sierra
Hi Jan, Short answer: no, because Java has no sizeof operator. You can use Java profiling tools to examine the memory usage of your app if needed. Since all of clojure's data structures are persistent (reusable), they won't necessarily meet your expectations for memory usage based on the

Re: thread-pool scope

2009-07-21 Thread Stuart Sierra
Hi Dan, I'm not sure, but closures actually sound like the way to go here. That would be the traditional functional-programming solution to this problem. It's true the Java equivalent is ugly, but that's because Java doesn't have real closures. :) -SS On Jul 20, 3:30 pm, Dan Fichter

Ant build.xml snippet: compile

2009-07-21 Thread Howard Lewis Ship
I've written an Ant build script snippet that locates .clj files and compiles them. Not tested on Windows. http://gist.github.com/151387 -- Howard M. Lewis Ship Creator of Apache Tapestry Director of Open Source Technology at Formos --~--~-~--~~~---~--~~ You

Re: Ant build.xml snippet: compile

2009-07-21 Thread Laurent PETIT
Hi Howard, Thanks for sharing that. One point though : I have a mitigate feeling with compiling all namespaces from the same JVM/Clojure environment. I understand that it makes the compilation go fast since ant does not need to relaunch the Compiler in a new jvm for each namespace, but I can see

Re: Dimming irrelevant stack trace frames

2009-07-21 Thread Mark Volkmann
On Mon, Jul 20, 2009 at 10:53 PM, Phil Hagelbergp...@hagelb.org wrote: One common criticism of Clojure is that the stack traces are... less than helpful. While it's true that the verbosity is great if you're debugging Clojure itself, I've found that more often it just obscures the important

Re: Emacs clojure mode: how to set current directory classpath

2009-07-21 Thread Phil Hagelberg
Baishampayan Ghose b.gh...@ocricket.com writes: Another question. Where do I put the clojure clojure-contrib JAR files? If you use the M-x clojure-install command, this should get all the dependencies. If you're getting stuck at the Polling stage, it's probably because you didn't do M-x

Re: Ant build.xml snippet: compile

2009-07-21 Thread Howard Lewis Ship
The other way of looking at these issues is that this style of compilation will *catch* these problematic issues. It seems to me that you should divide src/main/clojure into multiple source folders with an explicit ordering (say src/main/clojure and src/main/clojure-scripts) to distinguish

FYI Bug in Programming Clojure clojure download, wrt clojure.contrib.repl-utils/source

2009-07-21 Thread Alex Stoddard
I just discovered that clojure.contrib.repl-utils/source (described on page 40 of the book Programming Clojure) does not work with the version of the clojure.jar provided with the current code downloads for Programming Clojure. Core functions do not properly report their source with that version

Re: Clojure as a CGI language?

2009-07-21 Thread Jeff Marder
You could embed Jetty in your application and it will just work. If you want to get fancy later you could always run it behind Apache or lighttpd. I haven't done this myself with Clojure, but I've used an embedded Jetty for test cases in a plain Java application. It's very simple- probably much

Re: Clojure Workshop in London next Monday

2009-07-21 Thread AndrewC.
On Jul 14, 8:56 pm, Alex Scordellis alex.scordel...@gmail.com wrote: Next Monday evening we're hosting a Clojure Workshop at the ThoughtWorks offices in central London. Just wanted to say thanks to Alex for organising this. Got off to a good start by bumping into an old colleague in

Re: sizeof in Clojure

2009-07-21 Thread Daniel
On Tue, Jul 21, 2009 at 9:07 PM, Stuart Sierrathe.stuart.sie...@gmail.com wrote: Hi Jan, Short answer: no, because Java has no sizeof operator. You can use Java profiling tools to examine the memory usage of your app if needed. I would recommend heading down the path that Stuart

Re: Clojure Workshop in London next Monday

2009-07-21 Thread Jim Weirich
On Jul 14, 2009, at 8:56 PM, Alex Scordellis wrote: Next Monday evening we're hosting a Clojure Workshop at the ThoughtWorks offices in central London. Rats! I noticed this too late to make the event. Too bad, it looked like fun. -- -- Jim Weirich -- jim.weir...@gmail.com

Re: Dimming irrelevant stack trace frames

2009-07-21 Thread Mark McGranaghan
'clj-stacktrace.repl) (bad) (pst+) Where pst+ stands for print stack trace plus and prints a horizontally-aligned, cleanup-up, and color-coded stack trace to the console: http://img.skitch.com/20090721-efy2e4wgsrhxs2cxsbnu4c4ftx.png If you want to implement custom stacktrace-cleaning

Re: Improved Error Messages - Part XXXVIII

2009-07-21 Thread Mark Addleman
Here's another one: java.lang.IllegalArgumentException: Wrong number of args passed to: db $table It would be more helpful if the message included the number of actual versus expected arguments. For example: java.lang.IllegalAgumentException: Wrong number of args passed to :db $table.

Re: Ant build.xml snippet: compile

2009-07-21 Thread Laurent PETIT
Hi, so far my examples were more based on issues with namespaces separated into multiple pieces than on a namespace / script dichotomy. So while I understand the interest of separating source files to be delivered to production from test files, I don't see how this would solve both problems I

Re: Ant build.xml snippet: compile

2009-07-21 Thread Howard Lewis Ship
On Tue, Jul 21, 2009 at 3:17 PM, Laurent PETITlaurent.pe...@gmail.com wrote: Hi, so far my examples were more based on issues with namespaces separated into multiple pieces than on a namespace / script dichotomy. So while I understand the interest of separating source files to be delivered

Can (genclass) be changed to operate when not compiling?

2009-07-21 Thread Howard Lewis Ship
I'm using (:gen-class) to create javax.servlet.Filter, then creating a Jetty instance around the filter. Alas, for this to work, I have to go through my compile build to create the filter class so that I can let Jetty instantiate the filter. It would be nice if (gen-class), when not in compile

Protocol question: donating code to clojure-contrib

2009-07-21 Thread Howard Lewis Ship
I have some useful code related to regular expression parsing that I think would be useful as part of clojure-contrib. Is the protocol to add a ticket under Assembla first, or can I just update my fork and send a pull request to Rich? -- Howard M. Lewis Ship Creator of Apache Tapestry

Re: Can (genclass) be changed to operate when not compiling?

2009-07-21 Thread Chris Dean
Howard Lewis Ship hls...@gmail.com writes: It would be nice if (gen-class), when not in compile mode, would still create a class in memory that could be referenced by class name elsewhere in Clojure. +1 I would find this useful as well. Cheers, Chris Dean

Re: Dimming irrelevant stack trace frames

2009-07-21 Thread Howard Lewis Ship
This is a technique I've used in Tapestry and people like it. In the HTML, the excluded frames are invisible, but a toggle can make them visible (in a muted grey). Tapestry has a concept of an application package, and highlights those frames in bold blue so they stick out. That makes a big

Re: Uncle Bob: bowling meets Clojure

2009-07-21 Thread artg
What is group-frames? --art On Jul 21, 12:00 am, Mark Triggs mark.h.tri...@gmail.com wrote: Hi Stu, Stuart Halloway stuart.hallo...@gmail.com writes: Uncle Bob Martin, a very well-respected OO and agile guy, is learning   Clojure. He has posted an example [1] and asked for feedback from

Re: Protocol question: donating code to clojure-contrib

2009-07-21 Thread Chouser
On Tue, Jul 21, 2009 at 7:24 PM, Howard Lewis Shiphls...@gmail.com wrote: I have some useful code related to regular expression parsing that I think would be useful as part of clojure-contrib. Is the protocol to add a ticket under Assembla first, or can I just update my fork and send a pull

predicates in Programming Clojure

2009-07-21 Thread Jimmie Houchin
Hello, I am very excited about opportunities of what I can do in Clojure. I am a long time Squeaker (Smalltalk), and also Python user, dabbling at times in various other languages. I have briefly explored Scala as an option for my business app. But, I really am a dynamic typing guy. :) I

Bitfields access in Clojure

2009-07-21 Thread Daniel Janus
Dear list, Having a free day on my hands, I finally got around to writing some nontrivial code in Clojure. The result happens to be a library that I hope might be useful to someone else besides me. It's called clj- bitfields and consists of one macro, with-bitfields, that allow you to say things

Bitfields access in Clojure

2009-07-21 Thread Daniel Janus
Dear list, [I apologize in advance if this gets posted twice.] Having a free day on my hands, I finally got around to writing some nontrivial code in Clojure. The result happens to be a library that I hope might be useful to someone else besides me. It's called clj- bitfields and consists of

Re: Can (genclass) be changed to operate when not compiling?

2009-07-21 Thread Chouser
On Tue, Jul 21, 2009 at 8:04 PM, Howard Lewis Shiphls...@gmail.com wrote: Basically, what I want is for AOT to be an optional optimization, not a requirement.  Currently if your code relies on gen-class, AOT becomes necessary for operation, period. This is how gen-class used to behave.

Re: Emacs clojure mode: how to set current directory classpath

2009-07-21 Thread Glen Stampoultzis
2009/7/21 Anne Ogborn annie6...@yahoo.com While we're on this subject, anybody know the same information for La Clojure? That is, how to set up the current directory and classpath so one can compile java classes from Clojure? IntelliJ has many strengths, but a simple, transparent

Re: Can (genclass) be changed to operate when not compiling?

2009-07-21 Thread Adrian Cuthbertson
I get around this for servlets by combining gen-class and proxy in my servlet file; (ns my-servlets.MyServlet (:import (javax.servlet.http HttpServlet HttpServletRequest HttpServletResponse)) (:gen-class :extends HttpServlet) ) (defn req-do [#^HttpServlet svlt #^HttpServletRequest

Re: predicates in Programming Clojure

2009-07-21 Thread Meikel Brandmeyer
Hi, Am 21.07.2009 um 22:48 schrieb Jimmie Houchin: (defn is-small? [number] (if ( number 100) yes no )) Is is-small? a predicate? If so, is this a common pattern for such predicates? The definition is correct. is-small? is not a predicate. It returns a string. So (if (is-small? x)

Logging functions delegated to java logging systems

2009-07-21 Thread ataggart
I've written up a small set of logging functions to output from clojure what I'm already doing from my production java code. Currently it checks for the presence of commons-logging, log4j, and finally java.util.logging. The clojure code doesn't actually do any logging itself; instead everything