Re: with-open binding form

2008-10-13 Thread Allen Rohner
> I noticed with-open kind of stuck out because it doesn't use vectors > for binding like let, loop, and others. I had a similar comment about doseq. I don't think the obstacle is the technical challenge, but rather Rich's decision about whether to do it or not. This would be a breaking change, o

Re: Nested Multimethods

2008-10-13 Thread Stuart Halloway
Hi Patrick, How about: (defmulti length (fn [x] (if (= :stateMachine (:class x)) (:state x) (:class x (defmethod length :yardstick [x] 36) (defmethod length :walking [x] "short") (defmethod length :running [x] "long") user=> (lengt

Nested Multimethods

2008-10-13 Thread CuppoJava
Is there anyway to do the following with the existing multi-method facilities? There is a general multi-method length(object) that splits off to different methods depending on the :class of the object. And then specifically for objects with :class = :stateMachine, I want to define it's method to

Refs and ensure

2008-10-13 Thread jim
Rich, I've been working with refs tonight and I appreciate the validate-fn addition. Makes my life a lot easier. >From reading the docs, 'ensure' keeps a ref from changing inside a dosync. But if accesses to refs are contained in function calls that are called during the transaction, the progr

Re: java.lang.ExceptionInInitializerError in r1068

2008-10-13 Thread Perry
On Oct 13, 7:28 pm, Rich Hickey <[EMAIL PROTECTED]> wrote: > If you want to try it, you'll need to put ./gen in your classpath. Okay, good to know -- sorry for the noise, then. > 1068 generates and loads all classfiles to/from disk, as a prelude to > AOT compilation. I'm very excited about thi

Re: java.lang.ExceptionInInitializerError in r1068

2008-10-13 Thread Rich Hickey
On Oct 13, 8:14 pm, Perry <[EMAIL PROTECTED]> wrote: > Hi Rich, > > Hope this is a helpful report: I'm getting an > ExceptionInInitializerError in SVN revision 1068, on OS X 10.5.5, w/ > both Java 1.5 & 1.6. > 1068 is an interim release. If you want to try it, you'll need to put ./gen in your c

java.lang.ExceptionInInitializerError in r1068

2008-10-13 Thread Perry
Hi Rich, Hope this is a helpful report: I'm getting an ExceptionInInitializerError in SVN revision 1068, on OS X 10.5.5, w/ both Java 1.5 & 1.6. Transcript below. Best, Perry -- [mac_book]~/all_docs/software/clojure/svnhead $ svn info Path: . URL: https://clojure.svn.sourceforge.net/svnro

Re: GUIs in Clojure

2008-10-13 Thread Randall R Schulz
On Monday 13 October 2008 16:39, Martin DeMello wrote: > On Oct 13, 12:37 pm, JumpingJupiter <[EMAIL PROTECTED]> > > wrote: > > pretty verbose even for simply windows. Some parts could be > > shortened with some extra macro - menu's in particular, but I'm > > starting to think UI code is going to

Re: GUIs in Clojure

2008-10-13 Thread Martin DeMello
On Oct 13, 12:37 pm, JumpingJupiter <[EMAIL PROTECTED]> wrote: > pretty verbose even for simply windows. Some parts could be shortened > with some extra macro - menu's in particular, but I'm starting to > think UI code is going to look pretty ugly unless you drastically > limit the options for cus

with-open binding form

2008-10-13 Thread Kevin Downey
I noticed with-open kind of stuck out because it doesn't use vectors for binding like let, loop, and others. it was a quick fix using destructuring to make the macro use square backets example: (with-open [f (new java.io.FileWriter "test")] do-stuff) but as I was writing an email to this list I r

Re: help a journalist: why Clojure?

2008-10-13 Thread estherschindler
It's live! Thanks to everyone for their help. 6 Scripting Languages Your Developers Wish You'd Let Them Use Several up-and-coming scripting languages--some open-source--are gaining popularity among software developers. These dynamic programming languages, including Groovy, Scala, Lua, F#, Clojure

Re: help a journalist: why Clojure?

2008-10-13 Thread estherschindler
Thanks to everyone for their help -- the article is live! 6 Scripting Languages Your Developers Wish You'd Let Them Use Several up-and-coming scripting languages--some open-source--are gaining popularity among software developers. These dynamic programming languages, including Groovy, Scala, Lua,

Re: ClassNotFoundException for an fn in 1067

2008-10-13 Thread Rich Hickey
On Oct 13, 4:28 pm, Jeffrey Chu <[EMAIL PROTECTED]> wrote: > Hi, > > I'm having similar issues with r1067 in swank-clojure; but it's not > printing/reading fns. Instead it's reading, inserting vars, and > evaling. The weird thing is that I can't seem to reproduce it on a > small scale. Anyways,

Re: ClassNotFoundException for an fn in 1067

2008-10-13 Thread Jeffrey Chu
Hi, I'm having similar issues with r1067 in swank-clojure; but it's not printing/reading fns. Instead it's reading, inserting vars, and evaling. The weird thing is that I can't seem to reproduce it on a small scale. Anyways, that's my problem and I'll keep trying to figure it out. I found a diff

Re: GUIs in Clojure

2008-10-13 Thread JumpingJupiter
I wrote some code to enable declarative swing definitions pretty much identical in form to Michael's suggestion: (let [gui (swingset (JFrame frame {:setSize [500 500]} (JPanel panel {:setBackground (. Color orange)} (JLabel {:setText "Hello World

Re: ClassNotFoundException for an fn in 1067

2008-10-13 Thread Mike Hinchey
On Oct 13, 5:31 am, Rich Hickey <[EMAIL PROTECTED]> wrote: > You cannot, and might never be able to, print/read fns. Okay, it just looked like something that could be read. > > I would examine carefully whether your macro really should be doing > this, as this is likely to become disallowed once

Re: Formatted printing?

2008-10-13 Thread Rich Hickey
On Oct 13, 1:57 pm, "Michel Salim" <[EMAIL PROTECTED]> wrote: > On Sat, Oct 11, 2008 at 9:58 AM, Rich Hickey <[EMAIL PROTECTED]> wrote: > >> Starting from some Scheme or CL code is a good idea. I'll just adapt > >> it to support literal maps, vectors, and such. > > > A pretty-print for Clojure

Re: Formatted printing?

2008-10-13 Thread Michel Salim
On Sat, Oct 11, 2008 at 9:58 AM, Rich Hickey <[EMAIL PROTECTED]> wrote: >> Starting from some Scheme or CL code is a good idea. I'll just adapt >> it to support literal maps, vectors, and such. >> > > A pretty-print for Clojure would be a welcome contribution. In order > to be an acceptable contr

Re: Suggest changing update-in to accept additional args for "f"

2008-10-13 Thread mb
Hello, On 13 Okt., 17:02, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote: >         user=> (update-in m [:a :b] + 2) ; new >         {:a {:b 3}} I think this is a good idea. This would also be in-line with things like alter and commute. Sincerely Meikel --~--~-~--~~~

Re: Dealing with keyword-keyed maps in Java land

2008-10-13 Thread Paul Barry
Thanks Rich, that worked great. Here's what I ended up using: (in-ns 'velocity) (clojure/refer 'clojure) (import '(org.apache.velocity.app VelocityEngine)) (import '(org.apache.velocity.context Context)) (import '(java.io StringWriter)) (defn make-context [context] (proxy [Context] [] (c

Re: Dealing with keyword-keyed maps in Java land

2008-10-13 Thread Rich Hickey
On Oct 13, 10:17 am, Paul Barry <[EMAIL PROTECTED]> wrote: > To give a specific example of what I'm trying to do, I'd like to use > velocity templates in Clojure. So I have this code: > > (in-ns 'velocity) > (clojure/refer 'clojure) > > (import '(org.apache.velocity.app VelocityEngine)) > (impo

Suggest changing update-in to accept additional args for "f"

2008-10-13 Thread Stephen C. Gilardi
I've enclosed a modified definition of update-in that allows the update function "f" to take arguments in addition to "old" value being updated. The new definition does everything the old definition does (when additional arguments are not supplied), but it allows "f" to be an existing func

Re: Dealing with keyword-keyed maps in Java land

2008-10-13 Thread Paul Barry
To give a specific example of what I'm trying to do, I'd like to use velocity templates in Clojure. So I have this code: (in-ns 'velocity) (clojure/refer 'clojure) (import '(org.apache.velocity.app VelocityEngine)) (import '(org.apache.velocity VelocityContext)) (import '(java.io StringWriter))

Re: Dealing with keyword-keyed maps in Java land

2008-10-13 Thread Rich Hickey
On Oct 13, 9:34 am, Paul Barry <[EMAIL PROTECTED]> wrote: > I was thinking this is a little different because the Keyword data > type is unique to Clojure. So once in the Java land, you are never > going to want to use Keywords. In Clojure, I agree, the difference > between Keyword and String

Re: Dealing with keyword-keyed maps in Java land

2008-10-13 Thread Aaron Brooks
Having looked at Keyword.java, I'll amend my example: import clojure.lang.Keyword; x map.get(new Keyword("myns","foo")); The above may well reveal that I remember very little Java from previous lives so feel free to correct any errors. -Aaron. On Oct 13, 9:33 am, Aaron Brooks <[EMAIL P

Re: Dealing with keyword-keyed maps in Java land

2008-10-13 Thread Paul Barry
I'm thinking about cases where you are using existing java libraries that you don't want to/can't re-write to have Clojure specific code in them. I think the rule for dealing with conflicts would be to give me the value for the String if it's there, if it's not, try to give me the value for the K

Re: recur question

2008-10-13 Thread Stewart Griffin
2008/10/13 Stuart Halloway <[EMAIL PROTECTED]>: > > Hi Michael, > > The multiplication by n comes after the recur. > > Cheers, > Stuart > >> >> Giving the factorial function as: >> >> (def factorial >>(fn [n] (cond (= n 1) >> (> n 1) (* n (recur (dec n)) >> >> the comp

Re: Dealing with keyword-keyed maps in Java land

2008-10-13 Thread Paul Barry
I was thinking this is a little different because the Keyword data type is unique to Clojure. So once in the Java land, you are never going to want to use Keywords. In Clojure, I agree, the difference between Keyword and String should be explicit, but in Java, I feel like it's just pragmatic to

Re: Dealing with keyword-keyed maps in Java land

2008-10-13 Thread Aaron Brooks
All, I would think that changing or wrapping the map would create confusion and additional overhead. In my mind the most natural interaction would be to provide a way for Java code to create references to keywords: x = map.get(clojure.keyword("foo"));// ... or something along these lines

Re: are pr & friends correct for regexps?

2008-10-13 Thread Chouser
On Mon, Oct 13, 2008 at 9:06 AM, Stuart Halloway <[EMAIL PROTECTED]> wrote: > > (prn #"\\w+") > -> \w+ Works for me, SVN 1067: user=> #"\\w+" #"\\w+" user=> (prn #"\\w+") #"\\w+" nil --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscr

Re: Dealing with keyword-keyed maps in Java land

2008-10-13 Thread Stuart Halloway
Hi Paul, I think that I would rather see things remain explicit, i.e. if you need to interoperate with Java you convert manually before throwing the map over. In the Rails world they tried to solve a similar problem (string vs. symbol keys) by wrappering Hash to be indifferent between stri

are pr & friends correct for regexps?

2008-10-13 Thread Stuart Halloway
(prn #"\\w+") -> \w+ I was expecting something the reader could handle... Cheers, Stuart --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.c

Dealing with keyword-keyed maps in Java land

2008-10-13 Thread Paul Barry
Now that clojure maps are Java Maps, it is easier to inter-operate with Java code that has methods that take a Map as one of its arguments, because you can just pass the Map right into the Java code. The problem is that often times, the Java method is expecting the Map to have String values in th

Re: ClassNotFoundException for an fn in 1067

2008-10-13 Thread Rich Hickey
On Oct 13, 3:17 am, Mike Hinchey <[EMAIL PROTECTED]> wrote: > I know the #= and the AOT changes are new and not explained yet. It > seems to break a macro I'm writing, which does something like this > example. It does what I want in 1064, but not 1067. > > user> (defmacro aa [f x] `(~(var-get

Re: recur question

2008-10-13 Thread Stuart Halloway
Hi Michael, The multiplication by n comes after the recur. Cheers, Stuart > > Giving the factorial function as: > > (def factorial >(fn [n] (cond (= n 1) > (> n 1) (* n (recur (dec n)) > > the compiler complains "Can only recur from tail position". > Isn't really th

recur question

2008-10-13 Thread michael
Giving the factorial function as: (def factorial (fn [n] (cond (= n 1) (> n 1) (* n (recur (dec n)) the compiler complains "Can only recur from tail position". Isn't really the recur in tail position? It is the last expresson to be evaluated. --~--~-~--~---

ClassNotFoundException for an fn in 1067

2008-10-13 Thread Mike Hinchey
I know the #= and the AOT changes are new and not explained yet. It seems to break a macro I'm writing, which does something like this example. It does what I want in 1064, but not 1067. user> (defmacro aa [f x] `(~(var-get (resolve f)) ~x)) nil user> (aa inc 3) java.lang.ExceptionInInitializer