Re: Recommending Approach to Performance Critical Code

2008-11-06 Thread Mark H.
On Nov 6, 7:05 pm, CuppoJava <[EMAIL PROTECTED]> wrote: > I'm doing some heavy numerical matrix crunching and would like to > write it in as elegant a way as possible without sacrificing any > speed. Can you define "matrix crunching" more precisely? mfh --~--~-~--~~~-

Re: Having struggle in understanding FP (and Clojure question)

2008-11-06 Thread Mark H.
On Nov 6, 11:58 am, Konrad Hinsen <[EMAIL PROTECTED]> wrote: > On 05.11.2008, at 17:16, Mark H. wrote: > For the immediate future, yes. But with changing computer   > architectures, the existing algorithms and routines may lose much of   > their interest in the future. Haha, yes, we're working on

Re: Having struggle in understanding FP (and Clojure question)

2008-11-06 Thread cwyang
Thanks everyone. I've read all the replies, and I might understand something. (Though it seems that discussion goes to beyond my current understanding in the middle of this discussion threads) To explore further, I become another owner of 'Programming Clojure' :-) For my second question, I'll ke

Recommending Approach to Performance Critical Code

2008-11-06 Thread CuppoJava
I was wondering what's the recommended approach to performance code in Clojure. I'm doing some heavy numerical matrix crunching and would like to write it in as elegant a way as possible without sacrificing any speed. Is native arrays, and unchecked-arithmetic operations the way to go? Thanks f

Re: lancet: Clojure controlling Ant

2008-11-06 Thread Stuart Halloway
Carlos, I went down a similar road once before, using a Ruby DSL to generate the XML for Spring DI. This approach may offer the quickest initial return, but it hits a ceiling very quickly. You end up having two APIs with a totally unnecessary XML layer in between. Worse, the XML layer spe

Re: lancet: Clojure controlling Ant

2008-11-06 Thread Stuart Halloway
Stephen, You are absolutely right, and I hope to have all your syntax suggestions implemented tomorrow. By way of background: When I started, it seemed there were three obvious avenues to pursue: (1) write a Clojure DSL that generates the Ant XML (2) write a Clojure DSL that sticks close to

Re: Generalized Type Inference Optimization

2008-11-06 Thread Daniel Spiewak
> So you'd need a runtime instanceof test for Class, and use the > fastpath if true, reflection if not. > > Perf could be harder to pin down, as adding an import could cause > previously fast code to get slow. Actually, I was thinking of performing the inference based on *all* classes on the clas

Re: Generalized Type Inference Optimization

2008-11-06 Thread Rich Hickey
On Nov 6, 4:31 pm, Daniel Spiewak <[EMAIL PROTECTED]> wrote: > I've been perusing Stu Halloway's beta of "Programming Clojure" and I > came across the following example: > > (defn describe-class [c] > {:name (.getName c) >:final (java.lang.reflect.Modifier/isFinal (.getModifiers c))}) > >

Generalized Type Inference Optimization

2008-11-06 Thread Daniel Spiewak
I've been perusing Stu Halloway's beta of "Programming Clojure" and I came across the following example: (defn describe-class [c] {:name (.getName c) :final (java.lang.reflect.Modifier/isFinal (.getModifiers c))}) As demonstrated by the *warn-on-reflection* flag, Clojure is unable to determ

Re: lancet: Clojure controlling Ant

2008-11-06 Thread Stephen Wrobleski
On Thu, Nov 06, 2008 at 01:48:43PM -0500, Stuart Halloway wrote: > > Hi all, > > I am playing around with using Clojure to control Ant, something along > the lines of Groovy's Gant. I don't know how far I will take this-- > right now it is serving as a code example for the book. > > Two ques

Re: lancet: Clojure controlling Ant

2008-11-06 Thread carlitos
On Nov 6, 7:48 pm, Stuart Halloway <[EMAIL PROTECTED]> wrote: > I am playing around with using Clojure to control Ant, something along   > the lines of Groovy's Gant. [] I know next to nothing about ant, and what kind of control will lancet provide, but the proposed syntax reminds me of what

Re: jEdit Mode for Clojure

2008-11-06 Thread Daniel Spiewak
After I posted this, I realized that it was a little silly to talk about a Lisp editor mode without auto-indentation. It has been added! The main caveat is it doesn't seem to handle multiple unindents with the correctness I would like. For example: (defn say-hi [n] (println (str "Hello,

Re: Clojure Maven integration

2008-11-06 Thread Allen Rohner
On Nov 6, 1:20 pm, "Brian Doyle" <[EMAIL PROTECTED]> wrote: > Does anyone know of any Clojure maven integration? > What I'd like to see is something that will modify Clojure's > classpath updated based upon a given pom.xml file. > Thanks. There's this: http://www.bitbucket.org/achimpassen/cloj

Re: Having struggle in understanding FP (and Clojure question)

2008-11-06 Thread Konrad Hinsen
On 05.11.2008, at 17:16, Mark H. wrote: > and replace copies with destructive writes. I haven't seen a purely > functional formulation of LU factorization but it could be done > without too much trouble. Of course there's no reason to go through > that effort because people spend so much time o

Re: lancet: Clojure controlling Ant

2008-11-06 Thread Brian Doyle
On Thu, Nov 6, 2008 at 11:48 AM, Stuart Halloway <[EMAIL PROTECTED]>wrote: > > Hi all, > > I am playing around with using Clojure to control Ant, something along > the lines of Groovy's Gant. I don't know how far I will take this-- > right now it is serving as a code example for the book. > > Two

Re: Bug in genclass?

2008-11-06 Thread Michael Reid
Update: I used gen-and-save-class to see what it is complaining about. It is failing due to the following fields: public static final clojure.lang.Var printStackTrace-void__var; public static final clojure.lang.Var printStackTrace-PrintWriter__var; public static final clojure.lang.Va

Clojure Maven integration

2008-11-06 Thread Brian Doyle
Does anyone know of any Clojure maven integration? What I'd like to see is something that will modify Clojure's classpath updated based upon a given pom.xml file. Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

lancet: Clojure controlling Ant

2008-11-06 Thread Stuart Halloway
Hi all, I am playing around with using Clojure to control Ant, something along the lines of Groovy's Gant. I don't know how far I will take this-- right now it is serving as a code example for the book. Two questions: (1) Anybody interested in seeing lancet carried forward into a real proj

Bug in genclass?

2008-11-06 Thread Michael Reid
Hi, I am getting the following error trying to extend java.lang.Exception in the latest revision of Clojure: user=>(defmacro defexception [name] `(try (gen-and-load-class (quote ~name) :extends Exception) (catch java.lang.LinkageError le# (. le# (printStackTrace) user=> (

Re: jEdit Mode for Clojure

2008-11-06 Thread tkosan
Daniel wrote > Mostly for amusement, I created a jEdit mode for Clojure a while > back.  I don't get a chance to play with Clojure all that much, so it > hasn't been heavily tested ("go-to" *is* a Clojure "keyword", > right?).  ;-)  It's primarily based upon the Vim mode in terms of what > keywor

Re: prefer-method print-method problem

2008-11-06 Thread MikeM
> > Now *I'm* confused. It's your code that's printing "#=(sorted-map ..." > for me, without any call to "prefer-method" required. > > --Chouser Well, you're not the only one confused. I thought the "#=(sorted- map ..." came from boot.clj somehow, but I now realize my local REPL pulled in user.c

Re: prefer-method print-method problem

2008-11-06 Thread MikeM
I can reproduce what you did in a fresh local REPL (SVN 1075), but my server (also at SVN 1075) doesn't do this. I'm trying to find out how this can be. Any idea where I can find the code that generates the "#=(sorted-map ..." printing? I've looked but can't find it in boot.clj. Thanks for your h

Re: prefer-method print-method problem

2008-11-06 Thread Chouser
On Thu, Nov 6, 2008 at 10:01 AM, MikeM <[EMAIL PROTECTED]> wrote: > > I can reproduce what you did in a fresh local REPL (SVN 1075), but my > server (also at SVN 1075) doesn't do this. I'm trying to find out how > this can be. Any idea where I can find the code that generates the > "#=(sorted-map

Re: A trivial question about type and class

2008-11-06 Thread Chanwoo Yoo
I really appreciate your answer... and exciting 'Clojure', 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 To unsubscribe from t

Re: A trivial question about type and class

2008-11-06 Thread Chanwoo Yoo
Thanks hoeck and mb for your detailed explanation! Now I can understand your points. :) It's so exciting to read 'Programming Clojure', and I'm really happy that 'a lisp book' is printed from 'The Pragmatic Programmers', which is my favorite book publisher. --~--~-~--~~~---

Re: A trivial question about type and class

2008-11-06 Thread Rich Hickey
On Nov 6, 7:50 am, mb <[EMAIL PROTECTED]> wrote: > Hi, > > On 6 Nov., 13:30, Chanwoo Yoo <[EMAIL PROTECTED]> wrote: > > > > Is {:a 1} not a hash-map? It seems that there is some inconsistency... > > Clojure holds promises about the interface and the performance > characteristics of the provided

Re: prefer-method print-method problem

2008-11-06 Thread Chouser
On Thu, Nov 6, 2008 at 7:53 AM, MikeM <[EMAIL PROTECTED]> wrote: > > But when I try to prefer this: > > (prefer-method print-method clojure.lang.PersistentTreeMap > clojure.lang.IPersistentMap) You don't need this, because PersistentTreeMap is already a more specific type than IPersistentMap --

Re: sort with custom comparator

2008-11-06 Thread Chouser
On Thu, Nov 6, 2008 at 7:05 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > I was checking IFn.java first but couldn't see the Comparator > interface being listed there which made me writing my initial post. This is a more convenient and reliable way to check inheritance: (ancestors (class

Re: sort with custom comparator

2008-11-06 Thread Rich Hickey
On Nov 6, 2008, at 7:05 AM, [EMAIL PROTECTED] wrote: > > On Nov 6, 12:43 pm, Rich Hickey <[EMAIL PROTECTED]> wrote: >> On Nov 6, 5:23 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> >> wrote: >> >>> To answer my own question - AFn.java implements >>> java.util.Comparator. >> >> That is documented

prefer-method print-method problem

2008-11-06 Thread MikeM
I would like to print sorted maps readably (otherwise my sorted maps when printed and read back get turned into the default map), so I tried this: (defmethod print-method clojure.lang.PersistentTreeMap [o, #^java.io.Writer w] (let [eprint (fn eprint [e sep?] (do (print-method (key e) w)

Re: A trivial question about type and class

2008-11-06 Thread mb
Hi, On 6 Nov., 13:30, Chanwoo Yoo <[EMAIL PROTECTED]> wrote: > > Is {:a 1} not a hash-map? It seems that there is some inconsistency... Clojure holds promises about the interface and the performance characteristics of the provided functions. In general Clojure is a lot about abstract interfaces.

Re: A trivial question about type and class

2008-11-06 Thread hoeck
On Nov 6, 8:27 am, "Michael Wood" <[EMAIL PROTECTED]> wrote: > On Thu, Nov 6, 2008 at 8:25 AM, Chanwoo Yoo <[EMAIL PROTECTED]> wrote: > > > Hi all. In Stuart's book - Programming Clojure, there is a multi > > method like following: > > > (defmulti blank? class) > > (defmethod blank? String [s] (

Re: A trivial question about type and class

2008-11-06 Thread Chanwoo Yoo
Aha, I'm sorry for my laziness and spamming. {:a 1} is not a hash-map. I guess there is some reason of performance about this... Anyway, as mac pointed out, dispatching based on types will be inappropriate to clojure data structures. Thank you mac for the thread link~ user> (class {:a 1}) #=cloju

Re: A trivial question about type and class

2008-11-06 Thread Chanwoo Yoo
Thanks~ "clojure.lang.PersistentHashMap" works~ :) But I feel something is strange.. See next code, especially arrowed line. user> clojure.lang.PersistentHashMap #=clojure.lang.PersistentHashMap user> (= (class {:a 1 :b 2}) clojure.lang.PersistentHashMap) true user> (= (class {}) clojure.lang.Per

Re: sort with custom comparator

2008-11-06 Thread [EMAIL PROTECTED]
On Nov 6, 12:43 pm, Rich Hickey <[EMAIL PROTECTED]> wrote: > On Nov 6, 5:23 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: > > > To answer my own question - AFn.java implements java.util.Comparator. > > That is documented here: > > http://clojure.org/special_forms "IFns implement the Java C

Re: Concerned about Clojure's license choice.

2008-11-06 Thread [EMAIL PROTECTED]
On Nov 5, 5:53 pm, Matthias Benkard <[EMAIL PROTECTED]> wrote: > On Nov 5, 3:33 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > > Are you sure? You're not modifying the clojure source, so you're not > > creating a derivative work. I would think you can create a GPL > > licensed library in that case.

Re: sort with custom comparator

2008-11-06 Thread Rich Hickey
On Nov 6, 5:23 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > To answer my own question - AFn.java implements java.util.Comparator. > That is documented here: http://clojure.org/special_forms Rich --~--~-~--~~~---~--~~ You received this message because yo

Re: sort with custom comparator

2008-11-06 Thread [EMAIL PROTECTED]
To answer my own question - AFn.java implements java.util.Comparator. On Nov 6, 10:18 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > The doc of "sort" states that you need to implement > java.util.Comparator in order to use custom sorting. Why then does > this not cause any error? > > user=

sort with custom comparator

2008-11-06 Thread [EMAIL PROTECTED]
The doc of "sort" states that you need to implement java.util.Comparator in order to use custom sorting. Why then does this not cause any error? user=> (defn my-comp [x y] (cond (< x y) 1 (= x y) 0 :else -1)) #=(var user/my-comp) user=> (sort [5 3 1 2]) (1 2 3 5) user=> (sort my-comp [5 3 1 2]) (

Re: Patch: callable defstruct (PersistentStructMap$Def extends AFn)

2008-11-06 Thread Parth Malwankar
On Nov 6, 9:19 am, Chouser <[EMAIL PROTECTED]> wrote: > On Wed, Nov 5, 2008 at 12:10 AM, Chouser <[EMAIL PROTECTED]> wrote: > >  The attached patch allows: > > > user=> (point 42 11) > > {:x 42, :y 11} > Seems like a very nice enhancement to me. It would make the code more terse. Parth > The