Re: Got a Clojure library?

2009-04-09 Thread Brian Doyle
Name: clj-web-crawler URL: http://github.com/heyZeus/clj-web-crawler/tree/master Author: Brian Doyle Categories: Web, Automation License: MIT Dependencies: clojure, clojure-contrib, Apache commons-client 3.1 Description: clj-web-crawler is a wrapper around the Apache commons-client Java library tha

Question about metadata on map keys

2009-04-09 Thread Jason Wolfe
I just tracked down a bug in my code, which boiled down to this: user> ^(key (first (assoc {[] :old-val} (with-meta [] {:some :metadata}) :val))) nil Namely, if a map already contains a given key, when you attempt to assoc in a version of the key with new metadata this is not recorded. It seems

Amb operator

2009-04-09 Thread André Ferreira
So, I was wondering if anyone had implemented the amb operator in Clojure, so I decided to give it a try. This is my first Clojure program bigger then 5 lines, the code still needs ALOT of work, it is ugly as hell atm, but I think it kind of works. (Yes, I know, it's very easy to bug it, its just

Re: set-system-properties

2009-04-09 Thread Stuart Halloway
Yes to almost all of this (r662). I am not totally comfortable with the false/"false" conversion. Stu > Hi Stuart H! Comment on: > > (defn set-system-properties > [settings] > "Set some system properties. Nil clears a property." > (doseq [[name val] settings] >(if val > (System/se

Re: Java 6 dependency in clojure-contrib ok?

2009-04-09 Thread Scott Hickey
I would strongly recommend Java 5 and plan on staying with that version for a while if you have a goal seeing corporate uptake for Clojure. The Java version debate comes up every few months on the Groovy lists. The most common argument I've heard was that any company progressive enough to use a

Re: "Transparent" delays

2009-04-09 Thread Jason Wolfe
Hi Chas, Have you considered wrapping the computation in a lazy sequence? (lazy-seq [(expensive-calculation)]) The, instead of (force ...), you just use (first ...). I think equality and hashing will automatically work like you want them to. Cheers, Jason On Apr 9, 11:55 am, Chas Emerick wr

Re: reading properties file: does this helper already exist?

2009-04-09 Thread Perry Trolard
Hi Stu, > Too late :-). I have already committed (r659) -- take a look and see > if you are happy with the changes I made. > Stu Thanks -- looks great to me. One remark: how about returning a map from read-properties (by wrapping the body with (into {} ) )? I know you can just destructure t

Re: Java 6 dependency in clojure-contrib ok?

2009-04-09 Thread e
> > For what it's worth, I haven't upgraded from Tiger so I'm stuck with > Java 1.5, so I'd like to keep 1.5 compatibility. As an aside, I have Tiger and do stuff with Java 6 all the time. It's called soylatte: http://landonf.bikemonkey.org/static/soylatte/ The only thing is that I didn't kno

Re: Java 6 dependency in clojure-contrib ok?

2009-04-09 Thread Rayne
Our God has spoken. On Apr 8, 7:31 pm, Rich Hickey wrote: > On Apr 8, 7:52 pm, Stuart Halloway wrote: > > > Perry's proposed props functions > > (http://groups.google.com/group/clojure/browse_thread/thread/c8ec751b8... > > ) uses some Java 6 methods. > > > Is it ok for me to add such things to

Re: Is there a simple Clojure data schema/validation library?

2009-04-09 Thread John D. Hume
On Thu, Apr 9, 2009 at 11:58 AM, samppi wrote: > I've been whipping up a simple schema library for validating Clojure > data based on their tags, but I'm worried that what I'm doing might be > redundant with an already existing library. Is there something, such > as in clojure-contrib, that can d

Re: DISCUSS: tests that read and write files

2009-04-09 Thread Daniel Jomphe
Stuart Halloway wrote: > concerns: > (1) Would like to see the file after a failed test. > (2) [...] I would be much more   > comfortable not having to rely on code to write the file first.   > Doesn't feel like a unit test. > > But I am much more interested in having a shared approach that all  

Re: "Transparent" delays

2009-04-09 Thread Rich Hickey
On Apr 9, 2:55 pm, Chas Emerick wrote: > I recently came across a situation where I very much wanted to delay > the calculation of some values, but where I also wanted those delays > to use their calculated values for equality determinations. This is > particularly important when comparing vec

Re: DISCUSS: tests that read and write files

2009-04-09 Thread Victor Rodriguez
On Thu, Apr 9, 2009 at 3:57 PM, Stuart Halloway wrote: > > Three concerns: > > (1) Would like to see the file after a failed test. Unit tests should write their files to the temp directory (using the system property java.io.tmpdir). This way, unit tests do not pollute your project directory, an

Re: DISCUSS: tests that read and write files

2009-04-09 Thread Stuart Halloway
Three concerns: (1) Would like to see the file after a failed test. (2) Also have tests that read a file, and I would be much more comfortable not having to rely on code to write the file first. Doesn't feel like a unit test. (3) The macro is more complex than the code being tested. :-) (Th

Got a Clojure user group?

2009-04-09 Thread Rich Hickey
Got a Clojure user group, meetup etc? Reply to this message and let me know, I'll add them to the Clojure site. Please supply a primary URL for getting info for your group. Thanks! Rich --~--~-~--~~~---~--~~ You received this message because you are subscribed

"Transparent" delays

2009-04-09 Thread Chas Emerick
I recently came across a situation where I very much wanted to delay the calculation of some values, but where I also wanted those delays to use their calculated values for equality determinations. This is particularly important when comparing vectors or maps that contain delayed values,

Re: Programming Clojure Beta 9 Is Out

2009-04-09 Thread CuppoJava
Hi Stuart, Thanks very much for writing this book. Do you think the release of the completed book is pretty close? I'm very excited about it. -Patrick --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group.

OK, cobertura runs, but...

2009-04-09 Thread Stuart Halloway
I have Cobertura running and producing reports against contrib, sort-of. Problems: (1) AFAICT, cobertura *insists* in trying to parse the source code as Java to do cyclomatic complexity analysis. This blows up, of course. (2) The red/green coloring of the lines does not match what I know is

Re: clojure dependency management and build

2009-04-09 Thread Bradford Cross
On Thu, Apr 9, 2009 at 11:34 AM, Stuart Sierra wrote: > > I keep a "Clojure stuff" dir with the latest revisions of all the > projects I track -- Clojure, contrib, swank, slime, etc. -- and update > them all with a shell script that runs the various "svn update" and > "git pull" commands. So I al

Re: clojure dependency management and build

2009-04-09 Thread Stuart Sierra
I keep a "Clojure stuff" dir with the latest revisions of all the projects I track -- Clojure, contrib, swank, slime, etc. -- and update them all with a shell script that runs the various "svn update" and "git pull" commands. So I always have access to the latest version of everything. But I don

Re: reading properties file: does this helper already exist?

2009-04-09 Thread Stuart Sierra
By the way, recent versions of duck-streams assume UTF-8 unless you rebind *default-encoding*. -Stuart S. On Apr 8, 6:15 pm, Perry Trolard wrote: > Hi Stuart, > > Not sure if you saw my post athttp://bit.ly/sRnfG(links to list), or > the props.clj file in the Google Group. In short, it's got a >

Re: DISCUSS: tests that read and write files

2009-04-09 Thread Stuart Sierra
My recommendation would be to use a temporary file that is created and deleted in a macro or fixture. (defmacro with-tmp-properties-file [& body] `(binding [*tmp-properties-file* (File/createTempFile "temp" ".properties")] (spit *tmp-properties-file* "contents of the test file") ~...@

Re: getting code coverage into clojure-contrib builds?

2009-04-09 Thread Stuart Halloway
OK, I'll try Cobertura next. There is a reason my Java knowledge sounds about 5 years old ... :-) Stu > > Stuart Halloway wrote: >> I will go and bug the emma folks, but first wanted to ask here if >> there is any specific reason that Clojure-generated bytecode might >> surprise emma? > > I mig

Re: getting code coverage into clojure-contrib builds?

2009-04-09 Thread Daniel Jomphe
Stuart Halloway wrote: > I will go and bug the emma folks, but first wanted to ask here if > there is any specific reason that Clojure-generated bytecode might > surprise emma? I might be totally wrong, but from what I've heard, Emma's development has stopped a few years ago and it doesn't suppor

DISCUSS: tests that read and write files

2009-04-09 Thread Stuart Halloway
In r659 I added a unit test to clojure-contrib that needed to read and write from the filesystem. I picked a dumb and simple convention, and welcome review from other committers to move to something that is just- smart-enough. Stu --~--~-~--~~~---~--~~ You re

Re: reading properties file: does this helper already exist?

2009-04-09 Thread Stuart Halloway
Too late :-). I have already committed (r659) -- take a look and see if you are happy with the changes I made. Stu > As of 12:30 (Central Standard), a better props.1.5.clj is in Groups -- > sorry for the revision if you've already looked. > > Perry > > On Apr 9, 10:55 am, Perry Trolard wrote

Re: reading properties file: does this helper already exist?

2009-04-09 Thread Perry Trolard
As of 12:30 (Central Standard), a better props.1.5.clj is in Groups -- sorry for the revision if you've already looked. Perry On Apr 9, 10:55 am, Perry Trolard wrote: > I think the consensus is that 1.5 is the target, so I've attached > props.1.5.clj to the group, which is 1.5 compatiblle (i.e.

Re: New release of the enclojure plugin is up.

2009-04-09 Thread MarkH
Enclojure is shaping up to be a really nice development environment for Clojure. Great work Eric. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googleg

new contrib: singleton

2009-04-09 Thread Stuart Sierra
- clojure.contrib.singleton/singleton ([f]) Returns a memoized version of a function with no arguments. The memoized version caches the function's return value. This is useful for lazily creating global objects that are expensive to initialize. Warning: Make sure

getting code coverage into clojure-contrib builds?

2009-04-09 Thread Stuart Halloway
I spent a few minutes this morning trying to get an emma coverage report over contrib. Short answer is that it doesn't work -- emma throws an exception while instrumenting the code (see attached console.txt). I will go and bug the emma folks, but first wanted to ask here if there is any sp

Re: DISCUSS: clojure.contrib.java-utils/as-str

2009-04-09 Thread Meikel Brandmeyer
Hi, Am 09.04.2009 um 15:49 schrieb Stephen C. Gilardi: I like it for its simplicity. It can actually be a little simpler yet as the general case gives the same result when passed no arguments as the special case does: (defn as-str [& args] (apply str (map #(if (instance? clojure.lang.Nam

Is there a simple Clojure data schema/validation library?

2009-04-09 Thread samppi
I've been whipping up a simple schema library for validating Clojure data based on their tags, but I'm worried that what I'm doing might be redundant with an already existing library. Is there something, such as in clojure-contrib, that can do things similar to the code below (note the make-schema

Re: reading properties file: does this helper already exist?

2009-04-09 Thread Perry Trolard
I think the consensus is that 1.5 is the target, so I've attached props.1.5.clj to the group, which is 1.5 compatiblle (i.e. uses streams, not readers or writers). Best, Perry On Apr 8, 6:49 pm, Stuart Halloway wrote: > Perry, > > Cool -- I will add this pending the result of the Java 6 thread

Re: Java 6 dependency in clojure-contrib ok?

2009-04-09 Thread Jeffrey Straszheim
Yes to 5! I'm on a Mac and don't feel like dealing w/ upgrading to 6. On Thu, Apr 9, 2009 at 9:03 AM, Francesco Bellomi < francesco.bell...@gmail.com> wrote: > > Looks like an interesting idea for me; it would also allow for > automated dependency analysis for a given target jvm. > > btw, I'd al

Re: ANN: clj-android

2009-04-09 Thread Remco van 't Veer
On Thu, Apr 9, 2009 at 3:17 PM, Rich Hickey wrote: > On Apr 9, 8:03 am, "Remco van 't Veer" wrote: >> On Thu, Apr 9, 2009 at 1:23 PM, Onorio Catenacci wrote: >> > [..] >> >> > I know you were mentioning some real performance issues when starting >> > a Clojure app from Android (I see them too)

Re: Macros, let and variable capture

2009-04-09 Thread Paul Drummond
2009/4/9 Christophe Grand : > The problem is with the last two lines of your macro (the let expansion > is fine): > >      (.add l) >      (.add b > Do you really want to hardcode l and b here or emit as many .add as > required? No - this is where the macro is incomplete - these lines are jus

Re: clojure.main always exits with code 0

2009-04-09 Thread abedra
I have experienced this as well. My problem is that I would like my test suite to exit the proper way so that CI knows that the build actually failed. Currently test-is seems to just report to stdout, but not set anything that would cause the suite to fail with the proper exit code. Any ide

Re: Macros, let and variable capture

2009-04-09 Thread Christophe Grand
Hi Paul Paul Drummond a écrit : > (defmacro defwidget [& body] > `(let [panel# (javax.swing.JPanel.) >~@(flat1 (map (fn [[type inst]] [inst (list type)]) (rest (first > body] > ~(second body) > (doto panel# > (.setLayout (javax.swing.BoxLayout. panel# > javax.swing.B

Re: DISCUSS: clojure.contrib.java-utils/as-str

2009-04-09 Thread Stephen C. Gilardi
On Apr 9, 2009, at 2:57 AM, Eric Tschetter wrote: Might I suggest (defn as-str ([] "") ([& args] (apply str (map #(if (instance? clojure.lang.Named %) (name %) %) args))) I like it for its simplicity. It can actually be a little simpler yet as the general case gives the same result

Macros, let and variable capture

2009-04-09 Thread Paul Drummond
Hi, I am trying to define a macro something like this: (defwidget (vlayout (create-button b) (create-label l)) (on-event b "pressed" (fn [] (.setText l "Hello World" After a lot of messing around (I am learning all the time here!) I have a version of defwidget that ge

Re: ANN: clj-android

2009-04-09 Thread Rich Hickey
On Apr 9, 8:03 am, "Remco van 't Veer" wrote: > On Thu, Apr 9, 2009 at 1:23 PM, Onorio Catenacci wrote: > > [..] > > > I know you were mentioning some real performance issues when starting > > a Clojure app from Android (I see them too). I wonder if using > > TraceView to profile the Dalvik c

Re: Java 6 dependency in clojure-contrib ok?

2009-04-09 Thread Francesco Bellomi
Looks like an interesting idea for me; it would also allow for automated dependency analysis for a given target jvm. btw, I'd also prefer to have 1.5 compatibility Francesco On Apr 9, 2:24 am, Howard Lewis Ship wrote: > Looks like we need a macro: > > (for-jvm 1.5 () >              1.6 (..

Re: ANN: clj-android

2009-04-09 Thread Remco van 't Veer
On Thu, Apr 9, 2009 at 1:23 PM, Onorio Catenacci wrote: > [..] > > I know you were mentioning some real performance issues when starting > a Clojure app from Android (I see them too).  I wonder if using > TraceView to profile the Dalvik code generated by the conversion from > the Clojure bytecod

Re: New release of the enclojure plugin is up.

2009-04-09 Thread Laurent PETIT
Hi, FYI, it seems that the old web site of enclojure is still up and running, and not referencing the new wikispaces web site. HTH, -- Laurent 2009/4/7 Eric Thorsen > > There is a new release of the Enclojure plugin that addresses many of > the items I have seen discuss here recently with reg

Re: How to flatten a coll only 1 level deep?

2009-04-09 Thread Paul Drummond
2009/4/9 Chouser : > (defn flat1 [coll] >  (mapcat #(if (coll? %) % [%]) coll)) Ah, I see. So for each item, if its already a collection we leave it alone and if not we make a vector of one item, then at the end we use mapcat to concatinate all the top-level items into one list. Excellent - tha

Re: DISCUSS: clojure.contrib.java-utils/as-str

2009-04-09 Thread Paul Stadig
I think it makes sense for (str) to return "", but I'm not sure about (as-str) being "". It doesn't seem as obvious and expected to me. Paul On Thu, Apr 9, 2009 at 2:57 AM, Eric Tschetter wrote: > > Might I suggest > > (defn as-str > ([] "") > ([& args] >(apply str (map #(if (instance? c