Re: Concerns About Pushing Clojure 1.0.0 to Maven Central Repo?

2009-05-12 Thread Stefan Hübner
Daniel Renfer writes: > On Tue, May 12, 2009 at 4:51 PM, Howard Lewis Ship wrote: >> >> It's the answer to why the main artifact is called "clojure-lang" not >> just "clojure".  It's do differentiate Rich's framework, >> "clojure-lang", from the Contrib librarys ("clojure-contrib") even >> thou

Re: Macros applied to entire programs

2009-05-12 Thread Konrad Hinsen
On 13.05.2009, at 02:43, Mark Reid wrote: > Konrad, I agree, it would make more sense to add simple optimisations > like the one for addition to Clojure itself. However, the potential > problem you mention regarding the clash of multiple definitions of `+` > doesn't seem like that big an issue si

Re: Concerns About Pushing Clojure 1.0.0 to Maven Central Repo?

2009-05-12 Thread Daniel Renfer
On Tue, May 12, 2009 at 4:51 PM, Howard Lewis Ship wrote: > > It's the answer to why the main artifact is called "clojure-lang" not > just "clojure".  It's do differentiate Rich's framework, > "clojure-lang", from the Contrib librarys ("clojure-contrib") even > though they are both in the same Ma

Re: What is Contrib?

2009-05-12 Thread Laurent PETIT
Maybe, (just maybe :-) what doesn't help Rich see the real interesting candidate to core (or the most probable candidates, those that just do one thing by filling a gap, such as spit) could be placed in a more visible namespace. For example, placing carefully designed general small additions such a

Re: Breaking out of infinite loops

2009-05-12 Thread Laurent PETIT
I guess it may be defonce ( http://clojure.org/api#toc194 ) you're after, Regards, -- Laurent 2009/5/13 Mark Engelberg > > I often write code that I just want to run in an infinite loop. The > code generates lots of random things, and logs the interesting ones to > a file. > > In Python, I'd

Re: String.getBytes does not translate to byte[]?

2009-05-12 Thread Adrian Cuthbertson
Well, under the covers the str function applies the java "toString" method to any passed in object and hence the result could for some reason be different to the original String object passed in. I think this could occur if the object subclasses String, but has a different representation (i.e a di

Re: Concerns About Pushing Clojure 1.0.0 to Maven Central Repo?

2009-05-12 Thread Stefan Hübner
Hello Laurent, thanks for the summary! I'm looking forward to the decision and hope, we can move forward soon. -Stefan Laurent PETIT writes: > Hello, > > It seems that it's really a matter of convention, I don't see any technical > problem > of having a groupId of org.clojure and an artifact

Re: Concerns About Pushing Clojure 1.0.0 to Maven Central Repo?

2009-05-12 Thread Stefan Hübner
Hi Alex, ataggart writes: > I use Maven indirectly via Ivy, so I just wanted to request that, > whatever the choice of naming, the artifact and module names should > parallel. The reason for this request is that Ivy can resolve > dependencies in maven by creating URLs from a pattern. For exam

Breaking out of infinite loops

2009-05-12 Thread Mark Engelberg
I often write code that I just want to run in an infinite loop. The code generates lots of random things, and logs the interesting ones to a file. In Python, I'd write such code inside a try block that catches the Ctrl-C exception. So, when I want to use my computer for something else, I just h

Re: String.getBytes does not translate to byte[]?

2009-05-12 Thread tsuraan
> Maybe there's something about the particular [ s ] object that you're > passing in? I believe that you're right; in general, the getBytes seems to work. It is just in this one freakish case that it doesn't, but I have no idea how to tell what's special about my string. I'm not exactly proficie

Re: Macros applied to entire programs

2009-05-12 Thread Mark Reid
I should clarify: I asked my original question not because I wanted to actually write an optimiser but rather I was interested in how far the idea of code-modifying code could be pushed in a Lisp-like language such as Clojure. The example I gave was just the simplest thing I could think of that de

Re: String.getBytes does not translate to byte[]?

2009-05-12 Thread Adrian Cuthbertson
Using a java nio ByteBuffer to simulate what you're doing, the following works ok for me; (defmulti t-str class) (defmethod t-str String [s] (java.nio.ByteBuffer/wrap (.getBytes s "us-ascii"))) (t-str "abcde") # (defmethod t-str String [s] (java.nio.ByteBuffer/wrap (.getBytes s "utf-8")))

Documentation Flaw for "binding"

2009-05-12 Thread Curran Kelleher
Hello, Clojure's documentation is incredible, kudos to Rich Hickey! However I'd like to bring attention to one sentence in the docs which definitely needs revision: "Bindings created with binding can be assigned to, which provides a means for nested contexts to communicate with code before it th

Re: What is Contrib?

2009-05-12 Thread Daniel Lyons
On May 12, 2009, at 4:04 PM, Phil Hagelberg wrote: > Would love to hear what folks think about this. I am new here and new to Java and the JVM as well. Contrib strikes me as an improvement over the situation with Ruby where tons of code was dumped into the Ruby distribution and much of it ro

Re: What is Contrib?

2009-05-12 Thread e
to me symmetry is important. That is, consistency ... because it helps people know where to look. So, if slurp is in the core, spit should be in the core (but why not just use python's way more typical convention of "read() and "write()". Another example I recently saw is that "(nth)" is in the

Re: What is Contrib?

2009-05-12 Thread CuppoJava
I also, have a very vague sense (or perhaps just incorrect) of what contrib is. I am sharing my (possibly misguided) view because it's likely a lot of other people think similarly. Contrib seems to be a collection for user-created libraries for Clojure. They all seem to be in various stages of co

What is Contrib?

2009-05-12 Thread Phil Hagelberg
Now that Clojure 1.0 is out, I think it's a good time to take a look at contrib. I noticed it didn't get an official 1.0 release along with Clojure core. I wonder if this is because its role is just not very well-defined. Several people have expressed this opinion here on the mailing list and on

Bug in ClojureCLR in core-print.clj

2009-05-12 Thread jp
Hi, I've found that the capitalization is incorrect on lines 177 and 276 of core-print.clj. To reproduce it, enter the following forms: (print "hi") ; will hit line 177 (new System.Text.RegularExpressions.Regex ".") ; will hit 276 The error message is as following for both: System.MissingMethodE

String.getBytes does not translate to byte[]?

2009-05-12 Thread tsuraan
I'm trying to encode a java string into utf-8 for encapsulation within an OtpErlangBinary (http://erlang.org/doc/apps/jinterface/java/com/ericsson/otp/erlang/OtpErlangBinary.html). When I try to construct an OtpErlangBinary from the results of String.getBytes(encoding), I get bad data. A string

Re: Concerns About Pushing Clojure 1.0.0 to Maven Central Repo?

2009-05-12 Thread Laurent PETIT
Hello, It seems that it's really a matter of convention, I don't see any technical problem of having a groupId of org.clojure and an artifactId of clojure. Please let me try to summarize this never ending discussion: Currently the master build script is ant's build.xml. It generates clojure.jar

Re: Concerns About Pushing Clojure 1.0.0 to Maven Central Repo?

2009-05-12 Thread Howard Lewis Ship
It's the answer to why the main artifact is called "clojure-lang" not just "clojure". It's do differentiate Rich's framework, "clojure-lang", from the Contrib librarys ("clojure-contrib") even though they are both in the same Maven group. On Sun, May 10, 2009 at 8:36 AM, Phil Hagelberg wrote: >

Re: with-open macro

2009-05-12 Thread Emeka
Andrew, that code caused me to have headache some minutes ago :). On Tue, May 12, 2009 at 6:43 PM, Emeka wrote: > Why? > > > On Tue, May 12, 2009 at 5:37 PM, Andrew Wagner wrote: > >> Wow. Ok, yeah, I'm glad he didn't put that version in the article :) >> >> >> On Tue, May 12, 2009 at 1:17 PM, S

Re: with-open macro

2009-05-12 Thread Andrew Wagner
Oh, it's just significantly harder to read if you don't know clojure, that's all. On Tue, May 12, 2009 at 2:43 PM, Emeka wrote: > Why? > > > On Tue, May 12, 2009 at 5:37 PM, Andrew Wagner wrote: > >> Wow. Ok, yeah, I'm glad he didn't put that version in the article :) >> >> >> On Tue, May 12, 20

Re: with-open macro

2009-05-12 Thread Emeka
Why? On Tue, May 12, 2009 at 5:37 PM, Andrew Wagner wrote: > Wow. Ok, yeah, I'm glad he didn't put that version in the article :) > > > On Tue, May 12, 2009 at 1:17 PM, Stephen C. Gilardi wrote: > >> >> On May 12, 2009, at 12:30 PM, Andrew Wagner wrote: >> >>> It seems like this idiom would be ea

Re: Concerns About Pushing Clojure 1.0.0 to Maven Central Repo?

2009-05-12 Thread ataggart
I use Maven indirectly via Ivy, so I just wanted to request that, whatever the choice of naming, the artifact and module names should parallel. The reason for this request is that Ivy can resolve dependencies in maven by creating URLs from a pattern. For example: pulls from org/clojure/clojur

Re: Got a Clojure library?

2009-05-12 Thread Rich Hickey
On May 5, 9:10 am, Konrad Hinsen wrote: > On Jan 29, 2009, at 16:04, Rich Hickey wrote: > > > I'd like to try to get a directory ofClojurelibs together and up on > > theClojuresite. Towards that end, I'd appreciate it, if you are the > > author of aClojurelibrary(including contrib authors!), yo

Re: with-open macro

2009-05-12 Thread Andrew Wagner
Wow. Ok, yeah, I'm glad he didn't put that version in the article :) On Tue, May 12, 2009 at 1:17 PM, Stephen C. Gilardi wrote: > > On May 12, 2009, at 12:30 PM, Andrew Wagner wrote: > >> It seems like this idiom would be easy to implement in this macro. Or am I >> missing something? >> > > The c

Re: with-open macro

2009-05-12 Thread Stephen C. Gilardi
On May 12, 2009, at 12:30 PM, Andrew Wagner wrote: It seems like this idiom would be easy to implement in this macro. Or am I missing something? The current implementation of clojure.core/with-open works with multiple bindings the way you're advocating. The one in the article makes for an

Re: with-open macro

2009-05-12 Thread Meikel Brandmeyer
Hi, Am 12.05.2009 um 18:56 schrieb Andrew Wagner: Right, my question is why I can't do this: (with-open [rdr (reader file) writer (get-writer) foo (get-a-foo)] ...) In fact you can do and Clojure will close the Closables in reverse order. The information you found is outdated. Sincerely Mei

Re: with-open macro

2009-05-12 Thread Emeka
The reason is because Clojure obeys arity to the letter and spirit. So if you want to tweak the code to do that, just build you only macro to accept that arity. Emeka On Tue, May 12, 2009 at 4:56 PM, Andrew Wagner wrote: > Right, my question is why I can't do this:(with-open [rdr (reader file) >

Re: with-open macro

2009-05-12 Thread Andrew Wagner
Right, my question is why I can't do this:(with-open [rdr (reader file) writer (get-writer) foo (get-a-foo)] ...) On Tue, May 12, 2009 at 12:51 PM, Emeka wrote: > (with-open [rdr (reader file)] > ...) > So the vector you referred to is for binding and in imperative that means > assignin

Re: with-open macro

2009-05-12 Thread Emeka
(with-open [rdr (reader file)] ...) So the vector you referred to is for binding and in imperative that means assigning rdr to function (reader file). So now it is pretty obvious that what you need is the variable, rdr, (in side the scope) and that's why clojure takes only the first element

with-open macro

2009-05-12 Thread Andrew Wagner
I just saw this on the JavaWorld article (great article by the way: http://www.javaworld.com/javaworld/jw-05-2009/jw-05-clojure.html ) (defmacro with-open [bindings & body] `(let bindings (try @body (finally (

Re: JavaWorld article

2009-05-12 Thread Joshua Fox
The article I wrote just came out at JavaWorld (archived here) . Hopefully this article will influence Java developers to give Clojure a try. Thanks to Rich and to the whole Clojure community: The responsiv

Re: CL libraries - Newbie question

2009-05-12 Thread Daniel Lyons
On May 10, 2009, at 12:24 PM, Stuart Sierra wrote: > I'd never say this out loud on comp.lang.lisp, but I can't think of > any CL libraries for which there is not a functionally equivalent, > more robust, better-maintained Java library. > > Yeah, Java APIs aren't Lisp APIs. Whatever. Java libra

Re: More trouble with m-seq in a macro

2009-05-12 Thread samppi
That works perfectly. I forgot about macroexpand-1...but I also didn't think that the (1 2 3) list would be evaluated using 1 as a function too. Thanks both of you for the great help. On May 12, 8:33 am, "J. McConnell" wrote: > On Tue, May 12, 2009 at 11:22 AM, samppi wrote: > > > Oh, no...I u

Re: More trouble with m-seq in a macro

2009-05-12 Thread J. McConnell
On Tue, May 12, 2009 at 11:22 AM, samppi wrote: > > Oh, no...I understand now—it looks like I've incorrectly explained my > problem. > > I want to use the macro like this: (a 1 2 3) equivalent to (m-seq [1 2 > 3]). > > Clojure 1.0.0- > user=> (use 'clojure.contrib.monads) > nil > user=> (defn a [

Re: More trouble with m-seq in a macro

2009-05-12 Thread samppi
Oh, no...I understand now—it looks like I've incorrectly explained my problem. I want to use the macro like this: (a 1 2 3) equivalent to (m-seq [1 2 3]). Clojure 1.0.0- user=> (use 'clojure.contrib.monads) nil user=> (defn a [& xs] (with-monad maybe-m (m-seq xs))) #'user/a user=> (a 1 2 3) (1 2

Re: More trouble with m-seq in a macro

2009-05-12 Thread Konrad Hinsen
On May 12, 2009, at 16:40, samppi wrote: > I thought that: > `(with-monad maybe-m (m-seq ~xs))) > > would insert [1 2 3] where ~xs would be, becoming the list: > (with-monad maybe-m (m-seq [1 2 3])) It does, if you define your macro as (defmacro b [xs] `(with-monad maybe-m (m-seq ~xs))) Bu

Re: More trouble with m-seq in a macro

2009-05-12 Thread samppi
I see—thank you very much. But I suppose I don't understand how vector expressions work in macros. I thought that using ~@ would get me an argument error. I thought that: `(with-monad maybe-m (m-seq ~xs))) would insert [1 2 3] where ~xs would be, becoming the list: (with-monad maybe-m (m-seq [1

Re: Concerns About Pushing Clojure 1.0.0 to Maven Central Repo?

2009-05-12 Thread Daniel Jomphe
Laurent PETIT wrote: > > On 8 Mai, 01:39, Laurent PETIT wrote: > > > note that clojure must be compatible with JDK 1.5, so if you compile with > > > 1.6, maybe you should verify the compatibility mode (not sure if what I > > > write here makes sense, I'm not a specialist in javac retrocompatibili

Re: Macros applied to entire programs

2009-05-12 Thread Stuart Sierra
On May 12, 12:17 am, Mark Reid wrote: > I guess what I'm really looking for now is the "how". It's relatively easy to write a program that transforms Clojure source code: (loop [] (when-let [code (read *in* false nil)] ... do some transformation on code ... (prn transformed-co

Extending clojure.contrib.json.write/print-json

2009-05-12 Thread Josip Gracin
Hi! I'm querying a DB and getting java.sql.Timestamp in results, among other things. When I use print-json on this, timestamps are serialized as #. Stuart, any chance you could make the dispatch function for clojure.contrib.json.write/print-json more open for extensions? Unless I'm missing some

Re: Macros applied to entire programs

2009-05-12 Thread Sean Devlin
One thing hit me as I went to bed last night about this problem: Writing a macro to optimize an s-exp *is* writing a compiler. The good news is that you *don't* have to write a parser. There is some low hanging fruit here (like the + macro described above), but I imagine there will be a lot of

Re: Macros applied to entire programs

2009-05-12 Thread Paul Stadig
You could write a Clojure program that took in a Clojure program and spit out an optimized Clojure program. You could do something similar to the meta-circular evaluator, where you step through the program (which is just a data structure) recursively matching the head each time against different sy

Re: binding inside loop

2009-05-12 Thread Vincent Akkermans
Ah, I see. :) Thanks for your quick reply. Vincent On May 11, 8:54 pm, Rich Hickey wrote: > On May 11, 2:20 pm, Vincent Akkermans > wrote: > > > > > Hi all, > > > I'm building an application in which I want some function calls to be > > logged. However, when I have function A and B (both will

Re: Designing an SQL-based application

2009-05-12 Thread Janico Greifenberg
Thanks for your responses. I'm glad to see that I'm not entirely on the wrong track here. On Mon, May 11, 2009 at 6:39 PM, Sean Devlin wrote: > > Okay, good point about approach #2.  As I mentioned earlier, I'd use > approach #3 first.  Here's how I'd write your macro as a function > > (defn pro