Re: Measuring code complexity

2009-10-26 Thread Daniel Simms
On Mon, Oct 26, 2009 at 6:20 AM, Stuart Sierra wrote: > Can't be done.  Once a fn is compiled, it's just Java bytecode. On the other hand, size of the generated byte code is moderately interesting (as is runtime performance in time and heap). I do *love* the fact that the analysis can be done i

Re: KeyTest$_init_307.class vs KeyTest_init?

2009-10-26 Thread Gorsal
Sweet! So that worked. However, even though unlikely, i would like to avoid symbol collision. So i tried something like this (ns ide.handlers (:use clojure.contrib.with-ns)) (defmacro new-handler-class [classname-sym event & body] (let [hinted-this (with-meta 'this {:tag classname-sym})]

Re: SICP in Clojure

2009-10-26 Thread Robert Stehwien
On Sat, Oct 24, 2009 at 9:10 PM, John Harrop wrote: > On Sat, Oct 24, 2009 at 10:19 PM, Robert Stehwien wrote: > >> Hadn't seen it posted here yet: >> http://sicpinclojure.com/ >> > > Are they looking for help writing Clojure versions of the Scheme code > snippets? > > - > I'm not sure if the cr

Re: PATCH: AFn.java, RestFN.java (a better throwArity message)

2009-10-26 Thread MarkSwanson
Thanks for the link. I read somewhere that Rich asked folks to vet stuff on this Google Group first, so that's why I posted it here. I previously posted a "patch" to Clojure here and Rich applied it. I didn't have to do the CA, and if posting my patches into the public domain works - then please

Re: Measuring code complexity

2009-10-26 Thread kyle smith
Rather than the number of nodes in a tree, I think a better metric would be the number of edges in a graph. Variables that are referenced on many different lines should get double counted. I think this would explain why imperative spaghetti code is so complex. On the other hand, I suspect func

Re: add-watch's functions' first argument

2009-10-26 Thread samppi
Well, that's how the key itself is useful. What I'm wondering is why it is useful for the key to be passed to the watching function every time it's called. On Oct 26, 1:13 pm, pmf wrote: > On Oct 26, 8:12 pm, samppi wrote: > > > According to the docs, the function passed into an add-watch call

Re: doseq destructuring - weird behaviour

2009-10-26 Thread Meikel Brandmeyer
Hi, Am 26.10.2009 um 18:55 schrieb Abhijith: > (defn foobar [arr--of-arr] > (let [ acc (transient {}) ] >(doseq [ [i e] (indexed arr-of-arr) word e ] > (assoc! acc word (if-let [v (acc word)] (conj v i) [i]))) >(persistent! acc))) I think the problem is the wrong use of transients.

Re: PATCH: AFn.java, RestFN.java (a better throwArity message)

2009-10-26 Thread John Harrop
On Mon, Oct 26, 2009 at 1:55 PM, Jason Wolfe wrote: > Hi Mark, > > Thanks for the patch! Have you seen this page? > > http://clojure.org/contributing > > You should follow the instructions there to get your patch included. > In particular, that page tells you where to post it, and has other > de

Re: add-watch's functions' first argument

2009-10-26 Thread pmf
On Oct 26, 8:12 pm, samppi wrote: > According to the docs, the function passed into an add-watch call > receives four arguments. Its first argument is a "key". This key seems > to be the same key as the key passed into the add-watch call, and so > would always be the same, for the same ref and fu

add-watch's functions' first argument

2009-10-26 Thread samppi
According to the docs, the function passed into an add-watch call receives four arguments. Its first argument is a "key". This key seems to be the same key as the key passed into the add-watch call, and so would always be the same, for the same ref and function. What is the point of this argument

Re: doseq destructuring - weird behaviour

2009-10-26 Thread Chouser
On Mon, Oct 26, 2009 at 1:55 PM, Abhijith wrote: > > Hello everyone, >  I am having problems with destructuring in doseq. > > The function below basically takes an array of arrays as its argument > and returns a mapping of the elements to the index in the outer array. > > (use 'clojure.contrib.se

doseq destructuring - weird behaviour

2009-10-26 Thread Abhijith
Hello everyone, I am having problems with destructuring in doseq. The function below basically takes an array of arrays as its argument and returns a mapping of the elements to the index in the outer array. (use 'clojure.contrib.seq-utils) (defn foobar [arr--of-arr] (let [ acc (transient {})

Re: Scientific computing

2009-10-26 Thread liebke
I agree, use Clojure vectors whenever it's feasible. Even within Incanter, which uses Parallel Colt extensively, I try never to convert Clojure vectors into Colt vectors/matrices unless it's absolutely necessary. David On Oct 26, 2:23 pm, Konrad Hinsen wrote: > On 26 Oct 2009, at 17:14, Rock

Re: Scientific computing

2009-10-26 Thread Konrad Hinsen
On 26 Oct 2009, at 17:14, Rock wrote: > Just one more thing. It's still not really clear to me if I am better > off using Java arrays (make-array ...) or clojure vectors especially > when dealing with multidimensional arrays. I know that if use Java > libraries such as Colt, I have no choice. But

Re: PATCH: AFn.java, RestFN.java (a better throwArity message)

2009-10-26 Thread Jason Wolfe
Hi Mark, Thanks for the patch! Have you seen this page? http://clojure.org/contributing You should follow the instructions there to get your patch included. In particular, that page tells you where to post it, and has other details; for instance, you must send a CA to Rich before any code you

Re: PATCH: AFn.java, RestFN.java (a better throwArity message)

2009-10-26 Thread MarkSwanson
This seems like an even better place to post it: http://paste.lisp.org/display/89307 --~--~-~--~~~---~--~~ 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 Not

Re: Scientific computing

2009-10-26 Thread Garth Sheldon-Coulson
I imagine you'll be better off with the flexibility and ease of nested vectors unless you have very specific performance needs (e.g. you need to pass the arrays frequently to third-party libraries that accept Java arrays, or for performance reasons you want to mutate them in place using amap etc.)

Re: Scientific computing

2009-10-26 Thread Rock
Just one more thing. It's still not really clear to me if I am better off using Java arrays (make-array ...) or clojure vectors especially when dealing with multidimensional arrays. I know that if use Java libraries such as Colt, I have no choice. But in general? What do you think? On Oct 25, 5:3

Re: KeyTest$_init_307.class vs KeyTest_init?

2009-10-26 Thread Meikel Brandmeyer
Hi, On Oct 26, 2:35 pm, Gorsal wrote: > Im attempting to create a named class inside another namespace like > this: > > (ns ide.handlers >   (:import [org.eclipse.ui.commands AbstractHandler])) > > (defmacro new-handler-class [n event & body] >  `(do >       (ns ~n >         (:gen-class :extend

Re: Clojure in a big Java solution

2009-10-26 Thread Shantanu Kumar
You can probably settle for a set of Java data structures that are inter-operable with Clojure. 1. Use interfaces (because Clojure implements them too) such as java.util.List, java.util.Set, java.util.Map etc. 2. Use type hints and enable "warn on reflection". 3. When in Clojure, first convert to

Re: clojure / ruby yield comparison

2009-10-26 Thread Perry Trolard
> For example, the macro '->' changes this: > > (-> x (foo y) (bar z)) > > Into this: > > (foo (bar x z) y) Small correction. The result above should be: (bar (foo x y) z) user=> (macroexpand '(-> x (foo y) (bar z))) (bar (clojure.core/-> x (foo y)) z) Perry --~--~-~--~~

Re: Why can't :let be first in a for

2009-10-26 Thread Christopher Taylor
Dear all, I've got a re-implementation of the for-macro sitting around here that removes this limitation (and others, the vector can't be empty either, if I remember correctly). The implementation also adds the sorting and grouping functionality described in Wadler and Jones' paper "comprehensive

Re: KeyTest$_init_307.class vs KeyTest_init?

2009-10-26 Thread Gorsal
I just realize i wasn't putting those functions in an ns . So (defmacro new-handler-class [n event & body] `(do (ns ~n (:gen-class :extends ~'org.eclipse.ui.commands.AbstractHandler :init ~'init)) (binding [*ns* (find-ns '~n)] (defn ~'-init [] [[][]]) (defn ~

KeyTest$_init_307.class vs KeyTest_init?

2009-10-26 Thread Gorsal
Im attempting to create a named class inside another namespace like this: (ns ide.handlers (:import [org.eclipse.ui.commands AbstractHandler])) (defmacro new-handler-class [n event & body] `(do (ns ~n (:gen-class :extends ~'org.eclipse.ui.commands.AbstractHandler :init ~'init))

Re: Measuring code complexity

2009-10-26 Thread Stuart Sierra
On Oct 25, 11:56 pm, MarkSwanson wrote: > I'd like to run > count-nodes against a compiled fn that I've previously defined, but I > could not get an existing fn into quoted form Can't be done. Once a fn is compiled, it's just Java bytecode. -SS --~--~-~--~~~---~--~-

Re: Writing binary data using http.agent and duck-streams

2009-10-26 Thread Stuart Sierra
On Oct 23, 2:16 pm, Baishampayan Ghose wrote: > Is there any way to use duck-streams to write data as binary? No, duck-streams only does text. For binary I/O, you need the InputStream and OutputStream classes. -SS --~--~-~--~~~---~--~~ You received this message

Re: Equivalents from java

2009-10-26 Thread John Harrop
On Mon, Oct 26, 2009 at 8:01 AM, Gorsal wrote: > Thanks. Now i know to also use doc :) You're welcome. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@g

Re: Equivalents from java

2009-10-26 Thread Gorsal
Thanks. Now i know to also use doc :) --~--~-~--~~~---~--~~ 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 Note that posts from new members are moderated - plea

clojure@googlegroups.com

2009-10-26 Thread John Harrop
On Mon, Oct 26, 2009 at 4:18 AM, Cristian wrote: > I just started learning clojure and I tried to extend JButton, but I > keep getting a ClassFormatError when I try to instantiate the class. > > The problem started happening when I declared my own constructors. Can > I not declare a constructor wi

Re: News on Mini Kanren / Javascript generator; when is an implementation sufficiently original?

2009-10-26 Thread Michel Alexandre Salim
On Sun, Oct 25, 2009 at 6:28 PM, Rich Hickey wrote: > > On Sun, Oct 25, 2009 at 12:16 AM, Michel Salim > wrote: >> >> Jim was working on logic programming in Clojure up to a few months >> ago, and it seems as if the concern was that the code was too >> derivative. >> >> I have recently made avai

clojure@googlegroups.com

2009-10-26 Thread Cristian
I just started learning clojure and I tried to extend JButton, but I keep getting a ClassFormatError when I try to instantiate the class. The problem started happening when I declared my own constructors. Can I not declare a constructor with no arguments? Here's my test code. (ns test.gui.button

Re: Clojure in a big Java solution

2009-10-26 Thread vanallan
Hi thanks for the replies :) The whole system consists of a couple of hundreds of thousands lines of Java code. The part i am investigating is a validation sub system that validates a number of input parameters given from the user against various predefined values and rules, and against databases

Re: Measuring code complexity

2009-10-26 Thread Meikel Brandmeyer
Hi, On Oct 26, 7:08 am, John Harrop wrote: > >    (count-nodes "abcde") > >    ; 6 > > Yikes. > > Maybe special-casing strings would be best: change (seqable? x) into  (and > (seqable? x) (not (string? x))). I don't know if Seqable is synonymous with > that; might there be other seqable?s that

Re: binding and threads

2009-10-26 Thread Meikel Brandmeyer
Hi, On Oct 26, 3:58 am, samppi wrote: > I've read many, many times that binding allows you to give to vars > "thread-specific values", and that vars have a "thread-global value" > too. I think that I understand how vars and binding work, but I don't > understand how binding is necessarily relat

Re: clojure / ruby yield comparison

2009-10-26 Thread James Reeves
On Oct 25, 8:39 pm, Jarkko Oranen wrote: > Nitpick, but... The function closest to ruby's eval would be 'eval'. This is true, but doesn't mean what I said isn't true also. The closest thing to Ruby's eval is the Clojure eval function, and the closest thing to Clojure's macros in Ruby is eval. A