Re: get the total memory used by a data structure?

2010-12-22 Thread Alan
This can't really be done in a language that transparently handles pointers for you - who's "responsible" for some data that's pointed to by four different pointers? (let [a [1 2 [1 2]] b [2 [1 2]] c (next a)] (map total-memory [a b c])) What does this return? b and c are structural

Re: dispatching on a resulting range

2010-12-22 Thread Sunil S Nandihalli
yea Ken I agree with you.. but it was just an exercise .. you could definitely add a priority option to every method.. Thanks for your comments.. besides the code was tested.. Sunil. On Thu, Dec 23, 2010 at 11:45 AM, Ken Wesson wrote: > On Thu, Dec 23, 2010 at 1:09 AM, Ken Wesson wrote: > > An

Re: dispatching on a resulting range

2010-12-22 Thread Ken Wesson
On Thu, Dec 23, 2010 at 1:09 AM, Ken Wesson wrote: > An untested implementation: Yeah, there's a bug or two. > (def qlzqqlzuup (Object.)) > > (defmacro my-defmulti [name] >  `(def name Should be ~name. >     (let [dtable (atom (sorted-map))] Should be dtable#, and likewise the rest of the loc

Re: dispatching on a resulting range

2010-12-22 Thread Ken Wesson
On Wed, Dec 22, 2010 at 11:36 PM, Sunil S Nandihalli wrote: > the caveat is that the order in which you specify the methods would matter > .. since that is the order in which it is going to check for the appropriate > method to call.. Just like condp again. That seems sucky. What about adding a p

Re: Automatically unmapping unit tests from namespaces

2010-12-22 Thread Phil Hagelberg
On Dec 22, 8:54 am, Constantine Vetoshev wrote: > clojure-test-mode is pretty nice, but is there any way to make its > test namespace naming convention configurable? > > It currently expects src/com/company/project/file.clj to correspond to > test/com/company/project/test/file.clj. I prefer test/t

Re: about the repl

2010-12-22 Thread Tom Faulhaber
I have submitted a patch for pprint's tendency to mess up when exceeding *print-length*. I assume that Stuart will apply it to the 1.3 (master) branch RSN, unless he sees a problem with it. Sorry for the inconvenience. Tom On Dec 21, 12:30 am, Tom Faulhaber wrote: > Hmm, looks like I broke some

get the total memory used by a data structure?

2010-12-22 Thread Robert McIntyre
I think it would be really cool to have a function that gives the total number of bytes that a data structure consumes. so something like: (total-memory [1 2 [1 2]]) would return however many bytes this structure is. Is there already something like this around? Would it be hard to write to work

Re: dispatching on a resulting range

2010-12-22 Thread Sunil S Nandihalli
the caveat is that the order in which you specify the methods would matter .. since that is the order in which it is going to check for the appropriate method to call.. Just like condp again. On Thu, Dec 23, 2010 at 10:04 AM, Sunil S Nandihalli < sunil.nandiha...@gmail.com> wrote: > Hi Alex, >

Re: dispatching on a resulting range

2010-12-22 Thread Sunil S Nandihalli
Hi Alex, I have come across a similar need and I wrote the following macro which dispatches in a style similar to condp which can achieve what you are asking for .. https://gist.github.com/752567 basically instead of just having the dispatch-fn apply only on the

Re: Let's see how fast we can make this

2010-12-22 Thread Ken Wesson
On Wed, Dec 22, 2010 at 10:19 PM, Rayne wrote: > private static int countNumChars(String s) { >        int num = s.length(); >        for (int i = 0; i < s.length(); i++) { >                if (s.charAt(i) == ' ') { >                        num--; >                } >        } >        return num;

Re: Let's see how fast we can make this

2010-12-22 Thread Rayne
private static int countNumChars(String s) { int num = s.length(); for (int i = 0; i < s.length(); i++) { if (s.charAt(i) == ' ') { num--; } } return num; } Is one of the fastest I've seen. It runs around 4366.

dispatching on a resulting range

2010-12-22 Thread Alex Baranosky
Hi I've been playing with multimethods, and trying to see if there was a way to dispatch on a non-specific result of the dispatching function, such as a range, like this: (defn how-to-move [map1 map2] (+ (:cats map1) (:dogs map2))) (defmulti move how-to-move) (defmethod move 1 [map1 map2] (

Is swank-clojure.el deprecated?

2010-12-22 Thread limux
The clojure has released the 1.2 version, while swank-clojure.el is used 1.1 yet, Is swank-clojure deprecated at all? -- 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 ne

Re: Out of memory

2010-12-22 Thread Ken Wesson
On Wed, Dec 22, 2010 at 6:38 PM, David Nolen wrote: > On Wed, Dec 22, 2010 at 6:10 PM, Ken Wesson wrote: >> >> On Wed, Dec 22, 2010 at 6:08 PM, Chris Riddoch wrote: >> > On Wed, Dec 22, 2010 at 3:46 PM, David Nolen >> > wrote: >> >> A entire collection of 5e7 *objects* is being realized into me

Re: ANN: Clojure web application using NHPM for server push

2010-12-22 Thread rob levy
Hi Anders, thanks. If I understand what you are asking, in fact the server in my case does not care if anyone is listening, however you can set how long the messages live in the queue. The client holds the responsibility of keeping track of what messages it has already seen based on the date in t

Re: Out of memory

2010-12-22 Thread David Nolen
On Wed, Dec 22, 2010 at 6:10 PM, Ken Wesson wrote: > On Wed, Dec 22, 2010 at 6:08 PM, Chris Riddoch wrote: > > On Wed, Dec 22, 2010 at 3:46 PM, David Nolen > wrote: > >> A entire collection of 5e7 *objects* is being realized into memory as it > is > >> being reduced down to a single value to be

Re: Out of memory

2010-12-22 Thread Ken Wesson
On Wed, Dec 22, 2010 at 6:08 PM, Chris Riddoch wrote: > On Wed, Dec 22, 2010 at 3:46 PM, David Nolen wrote: >> A entire collection of 5e7 *objects* is being realized into memory as it is >> being reduced down to a single value to be stored into a var. I would expect >> this to perform poorly in a

Re: "classic" clojure-contrib 1.3.0-alpha4 released

2010-12-22 Thread Stuart Halloway
Nothing about multiple small bundles prevents doing a bigger bundled release as well. There continues to be a "kitchen sink" contrib, and there can be a "batteries included" build of the newer libs too. Repositories are orthogonal to build artifacts. On the other hand, building only a big bundl

Re: Out of memory

2010-12-22 Thread Chris Riddoch
On Wed, Dec 22, 2010 at 3:46 PM, David Nolen wrote: > A entire collection of 5e7 *objects* is being realized into memory as it is > being reduced down to a single value to be stored into a var. I would expect > this to perform poorly in any language. Range doesn't return a lazy seq? Or reduce so

Re: Out of memory

2010-12-22 Thread David Nolen
On Wed, Dec 22, 2010 at 5:32 PM, Chris Riddoch wrote > > If the workarounds mentioned actually work (I haven't tried) I really > don't understand why. This *looks* like a genuine bug to me, but I > really don't know Clojure's internals well enough (yet) to be able to > have the slightest hint wh

Re: Calling methods with a dollar sign in them

2010-12-22 Thread Daniel Werner
On 22 December 2010 23:22, Seth wrote: > ok, thats what i thought. Any change of a literal syntax for symbols > like in lisp, |symbol|?? There is no special reader syntax for weirdly named symbols, at least as far as I am aware, but you can always use: (symbol "strange$name") -- You received t

Re: Calling methods with a dollar sign in them

2010-12-22 Thread Sean Corfield
Since nested classes in Java get compiled to Outer$Inner, has any thought been given to allowing $ ? (Outer$Inner.) On Tue, Dec 21, 2010 at 12:30 PM, Stuart Sierra wrote: > Right now, probably not. But you can use the Java Reflection API to work > around it. -- You received this message becaus

Re: Out of memory

2010-12-22 Thread Chris Riddoch
On Wed, Dec 22, 2010 at 9:54 AM, Laurent PETIT wrote: > 2010/12/22 Jeff Palmucci >> >> I've worked around this sort of thing in the past by wrapping the >> initialization in a closure. My macros: > > Couldn't just it be a wrap with (let [] ), and let the choice of running it > once or not by choo

Re: Calling methods with a dollar sign in them

2010-12-22 Thread Seth
ok, thats what i thought. Any change of a literal syntax for symbols like in lisp, |symbol|?? -- 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

Re: "classic" clojure-contrib 1.3.0-alpha4 released

2010-12-22 Thread Sean Corfield
On Wed, Dec 22, 2010 at 11:50 AM, Mibu wrote: > For me as a user, the appeal of contrib was the bundling. ... > If you separate the libs then I can't see a difference or advantage > from the "third party" libs. When I first started using Clojure, I felt the bundling was very useful. Over time, I'

Re: Let's see how fast we can make this

2010-12-22 Thread David Powell
Wednesday, December 22, 2010, 6:52:01 PM, you wrote: > On my machine, your reduce example (I actually wrote that myself as my > first try) runs marginally slower than my loop example. I don't know > why you're getting such weird numbers. Your areduce example is worst > of all at 74072 on my machi

Re: Cannot recur across try

2010-12-22 Thread David Nolen
On Wed, Dec 22, 2010 at 3:43 PM, Amitava Shee wrote: > > Can someone more qualified than I explain why a recur from a try poses > a problem? > > I am copying the relevant parts of the source below > > clojure.tmbundle/Support/repl.clj > == > (defn repl > "runs a re

Cannot recur across try

2010-12-22 Thread Amitava Shee
While trying to make stephenroller's TextMate bundle (https:// github.com/stephenroller/clojure-tmbundle.git) work against Clojure 1.3.0-master-SNAPSHOT, I am running into the following exception Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMe

Re: "classic" clojure-contrib 1.3.0-alpha4 released

2010-12-22 Thread Ken Wesson
On Wed, Dec 22, 2010 at 2:50 PM, Mibu wrote: > For me as a user, the appeal of contrib was the bundling. I used to > just download the latest contrib jar, throw it in the classpath, and > have plenty of functionality that could be easily summoned using a > single line of code. Just like a standard

Re: "classic" clojure-contrib 1.3.0-alpha4 released

2010-12-22 Thread Mibu
For me as a user, the appeal of contrib was the bundling. I used to just download the latest contrib jar, throw it in the classpath, and have plenty of functionality that could be easily summoned using a single line of code. Just like a standard library, even though it's not officially standard. It

Re: Let's see how fast we can make this

2010-12-22 Thread David Nolen
On Wed, Dec 22, 2010 at 12:52 PM, Rayne wrote: > Running it gives me around 137343.295 nanoseconds. I've seen some Java > algorithms that could run at just under 3000 nanoseconds. > What do the Java implementations look like? (defn count-num-chars [^String s] (let [l (.length s) c (in

Re: *print-dup* and records

2010-12-22 Thread Brent Millare
Found an answer on stackoverflow http://stackoverflow.com/questions/4512790/how-do-i-use-print-dup-to-print-records-in-clojure-a-simple-case On Dec 22, 1:27 pm, Brent Millare wrote: > Hello, > > I'm trying to use *print-dup* to allow writing clojure data to a file > and then read it back, howeve

Re: Mocking multimethods

2010-12-22 Thread Brian Marick
> What are the cons of using midje? Any reason I shouldn't migrate all > my unit testing to it? I'm biased, but I think Midje is ready for production use. There's a smooth migration path because Midje uses the same reporting as clojure.test, so you can mix styles in the same file and still use

Re: Let's see how fast we can make this

2010-12-22 Thread Rayne
On my machine, your reduce example (I actually wrote that myself as my first try) runs marginally slower than my loop example. I don't know why you're getting such weird numbers. Your areduce example is worst of all at 74072 on my machine. On Dec 22, 12:39 pm, David Powell wrote: > Hi, > > > I ha

Re: My first Clojure program: request for code review

2010-12-22 Thread Ken Wesson
On Wed, Dec 22, 2010 at 1:14 PM, Benny Tsai wrote: > Hi Ken, > >> user=> (let [[x y & more] [1 2 3 4 5]] [x y more]) >> [1 2 (3 4 5)] >> user=> (let [[x y z] [1 2 3 4 5]] [x y z]) >> [1 2 3] >> user=> (let [[_ _ a b] [1 2 3 4 5]] [a b]) >> [3 4] >> >> You can grab any fixed position in this way, a

Re: Let's see how fast we can make this

2010-12-22 Thread David Powell
Hi, > I have a piece of code, and I'd like to see how fast it can be. > (defn count-num-chars [^String s] > (loop [s s acc 0] > (if (seq s) > (recur (rest s) (if (= (first s) \space) acc (inc acc))) > acc))) I get an average of 46928 for this. But for the straightforward opti

Re: Let's see how fast we can make this

2010-12-22 Thread Ken Wesson
On Wed, Dec 22, 2010 at 1:19 PM, Rayne wrote: > chouser wrote a solution earlier. I and a buddy modified it (a very > little) bit and managed to get it pretty blazing: > > ra...@ubuntu:~$ cake run ~/challenge.clj > Chars outputted: 460 > Time (in nanoseconds): 5768.677 > > Here is the function: >

Re: Working with protocols

2010-12-22 Thread David Nolen
On Wed, Dec 22, 2010 at 1:29 PM, Nicolas Buduroi wrote: > On Dec 22, 1:03 pm, David Nolen wrote: > > (Foo.) is a Java method call determined at compile-time. If you change > the > > definition of the Foo type/record, create-foo will be out of date. > Default > > constructor fns could alleviate t

Re: Let's see how fast we can make this

2010-12-22 Thread Rayne
Also, forgot to add an unchecked-int: (defn count-num-chars [^String s] (let [len (.length s) space (int 32)] (loop [i (int 0), c (int 0)] (if (< i len) (recur (unchecked-inc i) (if (== (int (.charAt s i)) space) c (unchecked-inc

Re: Working with protocols

2010-12-22 Thread Nicolas Buduroi
On Dec 22, 1:03 pm, David Nolen wrote: > (Foo.) is a Java method call determined at compile-time. If you change the > definition of the Foo type/record, create-foo will be out of date. Default > constructor fns could alleviate this but I think some design/modularity > issues need to be hashed out.

Re: Let's see how fast we can make this

2010-12-22 Thread Rayne
I actually pasted the wrong code here: (defn count-num-chars [^String s] (let [len (.length s) space (int 32)] (loop [i (int 0), c (int 0)] (if (< i len) (recur (inc i) (if (== (int (.charAt s i)) space) c (unchecked-inc c)))

Re: Let's see how fast we can make this

2010-12-22 Thread David Nolen
On Wed, Dec 22, 2010 at 1:22 PM, Ken Wesson wrote: > > (defn count-num-chars [^String s] > (let [l (int (.length s))] >(loop [i (int 0) acc (int 0)] > (if (< i l) >(recur (unchecked-inc i) (if (= (.charAt s i) \space) acc > (unchecked-inc acc))) >acc > > 15k nsec --

*print-dup* and records

2010-12-22 Thread Brent Millare
Hello, I'm trying to use *print-dup* to allow writing clojure data to a file and then read it back, however, I'm getting problems even with this simple case. Is there something I am doing wrong? What do I need to do to get this to work? Clojure 1.3.0-alpha3-SNAPSHOT user=> (defrecord TreeNode [va

Re: My first Clojure program: request for code review

2010-12-22 Thread David Nolen
On Wed, Dec 22, 2010 at 1:22 PM, David Nolen wrote: > On Wed, Dec 22, 2010 at 1:14 PM, Benny Tsai wrote: > >> Hi Ken, >> >> > user=> (let [[x y & more] [1 2 3 4 5]] [x y more]) >> > [1 2 (3 4 5)] >> > user=> (let [[x y z] [1 2 3 4 5]] [x y z]) >> > [1 2 3] >> > user=> (let [[_ _ a b] [1 2 3 4 5]

Re: My first Clojure program: request for code review

2010-12-22 Thread David Nolen
On Wed, Dec 22, 2010 at 1:14 PM, Benny Tsai wrote: > Hi Ken, > > > user=> (let [[x y & more] [1 2 3 4 5]] [x y more]) > > [1 2 (3 4 5)] > > user=> (let [[x y z] [1 2 3 4 5]] [x y z]) > > [1 2 3] > > user=> (let [[_ _ a b] [1 2 3 4 5]] [a b]) > > [3 4] > > > > You can grab any fixed position in th

Re: Let's see how fast we can make this

2010-12-22 Thread Ken Wesson
On Wed, Dec 22, 2010 at 12:52 PM, Rayne wrote: > I have a piece of code, and I'd like to see how fast it can be. > > (defn count-num-chars [^String s] >  (loop [s s acc 0] >    (if (seq s) >      (recur (rest s) (if (= (first s) \space) acc (inc acc))) >      acc))) > > This is the fastest I've be

Re: Let's see how fast we can make this

2010-12-22 Thread Rayne
chouser wrote a solution earlier. I and a buddy modified it (a very little) bit and managed to get it pretty blazing: ra...@ubuntu:~$ cake run ~/challenge.clj Chars outputted: 460 Time (in nanoseconds): 5768.677 Here is the function: (defn count-num-chars [^String s] (let [len (.length s)

Re: Let's see how fast we can make this

2010-12-22 Thread nicolas.o...@gmail.com
Which version of Clojure are you using? (How to speed that up depends a lot of the version you use) I would like to see a with a longer run. Optimised clojure is *asymptotically* nearly as fast as Java. With under 1000 calls I am not sure the JIT is called. Best, Nicolas. On Wed, Dec 22, 2010

Re: My first Clojure program: request for code review

2010-12-22 Thread Benny Tsai
> Just FYI, it's not applicable here but there is also rseq, which > returns a reversed view on a collection in constant time. It only > works on vectors and sorted maps, though. Good stuff, thank you Justin :) -- You received this message because you are subscribed to the Google Groups "Clojure

Re: My first Clojure program: request for code review

2010-12-22 Thread Benny Tsai
Hi Ken, > user=> (let [[x y & more] [1 2 3 4 5]] [x y more]) > [1 2 (3 4 5)] > user=> (let [[x y z] [1 2 3 4 5]] [x y z]) > [1 2 3] > user=> (let [[_ _ a b] [1 2 3 4 5]] [a b]) > [3 4] > > You can grab any fixed position in this way, as well as a "rest" that > is the tail of the sequence past the

Re: Working with protocols

2010-12-22 Thread David Nolen
On Wed, Dec 22, 2010 at 12:53 PM, Nicolas Buduroi wrote: > Hi, I've been working lately on my first project (https://github.com/ > budu/lobos) that use protocols. Up until now, it's been quite > infuriating, I can't stop getting seemingly random "No implementation > of method" exceptions and I rea

Working with protocols

2010-12-22 Thread Nicolas Buduroi
Hi, I've been working lately on my first project (https://github.com/ budu/lobos) that use protocols. Up until now, it's been quite infuriating, I can't stop getting seemingly random "No implementation of method" exceptions and I really don't understand why. For example here's what happened this m

Let's see how fast we can make this

2010-12-22 Thread Rayne
I have a piece of code, and I'd like to see how fast it can be. (defn count-num-chars [^String s] (loop [s s acc 0] (if (seq s) (recur (rest s) (if (= (first s) \space) acc (inc acc))) acc))) This is the fastest I've been able to get it. The function is very simple. It takes a s

Re: My first Clojure program: request for code review

2010-12-22 Thread Ken Wesson
On Wed, Dec 22, 2010 at 12:31 PM, Laurent PETIT wrote: > > > 2010/12/22 Ken Wesson >> >> On Wed, Dec 22, 2010 at 10:59 AM, Benny Tsai wrote: >> > Hi Marek, >> >> Great! I was wondering whether Clojure supports something like >> >> tuple-unpacking in Python. Does it also support "patterned" >> >>

Re: My first Clojure program: request for code review

2010-12-22 Thread Justin Kramer
On Dec 22, 10:59 am, Benny Tsai wrote: > > It does, but doesn't that make it less lazy? To reverse something, it > > needs to evaluate the whole sequence. I yet have to learn how to > > deal with lazyness. > You're right, I hadn't realized 'reverse' is not lazy (I have a lot to > learn about lazyn

Re: My first Clojure program: request for code review

2010-12-22 Thread Laurent PETIT
2010/12/22 Ken Wesson > On Wed, Dec 22, 2010 at 10:59 AM, Benny Tsai wrote: > > Hi Marek, > >> Great! I was wondering whether Clojure supports something like > >> tuple-unpacking in Python. Does it also support "patterned" > >> destructuring like: > >> > >> first, *middle, last = sequence(...) >

Re: My first Clojure program: request for code review

2010-12-22 Thread Ken Wesson
On Wed, Dec 22, 2010 at 10:59 AM, Benny Tsai wrote: > Hi Marek, >> Great! I was wondering whether Clojure supports something like >> tuple-unpacking in Python. Does it also support "patterned" >> destructuring like: >> >> first, *middle, last = sequence(...) >> -or- >> first, rest = sequence(...)

Re: Out of memory

2010-12-22 Thread Laurent PETIT
2010/12/22 Jeff Palmucci > I've worked around this sort of thing in the past by wrapping the > initialization in a closure. My macros: > > (defmacro once-fn "Define a function that should only be called once. > Releases local storage earlier" > [args & body] > `(^{:once true} fn* ~args ~...@bod

Re: Automatically unmapping unit tests from namespaces

2010-12-22 Thread Constantine Vetoshev
On Dec 21, 7:16 pm, Phil Hagelberg wrote: > If you're already using swank then you can try clojure-test-mode; it > clears out all deftests in between test runs. > > https://github.com/technomancy/clojure-mode/blob/master/clojure-test-... > > It also highlights failures in the test buffer for bette

Re: Automatically unmapping unit tests from namespaces

2010-12-22 Thread gaz jones
you can also move to the failed test and press C-c ' and it will show them in the mini-buffer On Tue, Dec 21, 2010 at 11:47 PM, Michael Ossareh wrote: > > > On Tue, Dec 21, 2010 at 21:36, Michael Ossareh wrote: >> >> On Tue, Dec 21, 2010 at 16:16, Phil Hagelberg wrote: >>> >>> It also highlight

Re: Out of memory

2010-12-22 Thread Jeff Palmucci
I've worked around this sort of thing in the past by wrapping the initialization in a closure. My macros: (defmacro once-fn "Define a function that should only be called once. Releases local storage earlier" [args & body] `(^{:once true} fn* ~args ~...@body)) (defmacro top-level-run "work aro

Re: My first Clojure program: request for code review

2010-12-22 Thread Benny Tsai
Hi Marek, > > - To sort the nicks by karma in descending order, instead of sorting > > by the negation of the karma, I used (reverse (sort-by ...)); again, > > just a subjective thing, makes the intent more clear to me. > > It does, but doesn't that make it less lazy? To reverse something, it > ne

Re: Mocking multimethods

2010-12-22 Thread Alex Baranosky
I love Midje and think migrating all the tests to it is a great idea. -- 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 - please be patient with

Re: Mocking multimethods

2010-12-22 Thread Alyssa Kwan
Thanks, Brian! I obviously didn't understand the nature of the provided form. That's really cool notation! This is exactly what I want. What are the cons of using midje? Any reason I shouldn't migrate all my unit testing to it? Thanks! Alyssa On Dec 22, 9:46 am, Brian Marick wrote: > On Dec

Re: Mocking multimethods

2010-12-22 Thread Brian Marick
On Dec 22, 2010, at 6:52 AM, Alyssa Kwan wrote: > The issue is where do I specify that: > (undo-fn ...patch...) => (fn [] (reset! visible-evidence-of-a-side- > effect :happened!)) The code you quoted is that specification. It doesn't matter that undo-fn is a multimethod. Here's what the notat

Re: Calling Clojure from Java

2010-12-22 Thread Laurent PETIT
2010/12/22 Mark Engelberg > I've decided to go with the old gen-class approach (mainly so I can > take advantage of the "state" option). > I'm running into a problem implementing Iterable. > The following lines in gen-class create a conflict: > :implements [java.lang.Iterable] > :methods [[it

Re: Calling Clojure from Java

2010-12-22 Thread Mark Engelberg
I've decided to go with the old gen-class approach (mainly so I can take advantage of the "state" option). I'm running into a problem implementing Iterable. The following lines in gen-class create a conflict: :implements [java.lang.Iterable] :methods [[iterator [] java.util.Iterator]] It com

Re: Clojure, Parallel programming and Leslie Lamport

2010-12-22 Thread Johann Hibschman
Konrad Hinsen writes: > Thanks for the link! Judging from the example in the README, it's a > library for task farming in Clojure. While that's a limited form of > parallelism, there are still lots of applications where it is useful, > so I'd say this library is definitely worth a closer look. Ho

Re: Clojure, Parallel programming and Leslie Lamport

2010-12-22 Thread Konrad Hinsen
On 22 Dec 2010, at 14:02, Sunil S Nandihalli wrote: I am interested in distributed parallel computing too ... I have prior experience coding with MPI and c .. but that besides the point .. while I was looking at options with clojure .. I recently came across swarmiji. https://github.com/am

Re: Clojure, Parallel programming and Leslie Lamport

2010-12-22 Thread Sunil S Nandihalli
Hello Tim and Konrad, I am interested in distributed parallel computing too ... I have prior experience coding with MPI and c .. but that besides the point .. while I was looking at options with clojure .. I recently came across swarmiji. https://github.com/amitrathore/swarmiji I don't know much t

Re: Mocking multimethods

2010-12-22 Thread Alyssa Kwan
The issue is where do I specify that: (undo-fn ...patch...) => (fn [] (reset! visible-evidence-of-a-side- effect :happened!)) undo-fn is a multimethod in my design, which requires a corresponding defmethod for each patch type. I need to create one for the scope of the test, but defmethod by defin

Re: Mocking multimethods

2010-12-22 Thread Alyssa Kwan
I'd like to discuss this design approach. (It's unrelated to the testing issue.) I avoided this design because the undo-fn is determined at do-patch! time. The use case is for a persistent system like Git where patches may be undone long after being done - e.g. long after the patch is written to

Re: Mocking multimethods

2010-12-22 Thread Brian Marick
I think I misunderstand the issue, because this works for me: (ns midje.util.git (:use [midje.sweet])) ;; Code except for undo-patch is the same as before. ;; ... ;; I pulled remove-patch out of undo-patch because I was ;; getting a screwy read error I didn't want to figure out ;; at 5 in the

Re: Calling Clojure from Java

2010-12-22 Thread Laurent PETIT
2010/12/22 Chas Emerick > > On Dec 22, 2010, at 4:58 AM, Laurent PETIT wrote: > > > There's also this issue raised in the bug tracker (by Chas Emerick I > presume ?) which is about adding a nice java facade for this kind of interop > (and thus also ensuring some independance towards clojure inter

Re: Calling Clojure from Java

2010-12-22 Thread Chas Emerick
On Dec 22, 2010, at 4:58 AM, Laurent PETIT wrote: > There's also this issue raised in the bug tracker (by Chas Emerick I presume > ?) which is about adding a nice java facade for this kind of interop (and > thus also ensuring some independance towards clojure internals). > > What about bringin

Re: Calling Clojure from Java

2010-12-22 Thread Alex Osborne
Mark Engelberg writes: > Looks easy, but your dance and speak methods don't return a value > which leaves a question in my mind... > > If the protocol implementation actually returns a value, do you have > to explicitly typecast it in Java from Object into the desired type? Yep, certainly. A Cl

Re: Calling Clojure from Java

2010-12-22 Thread Laurent PETIT
2010/12/22 Mark Engelberg > Looks easy, but your dance and speak methods don't return a value > which leaves a question in my mind... > > If the protocol implementation actually returns a value, do you have > to explicitly typecast it in Java from Object into the desired type? > Yes -- You rec

Re: Calling Clojure from Java

2010-12-22 Thread Mark Engelberg
Looks easy, but your dance and speak methods don't return a value which leaves a question in my mind... If the protocol implementation actually returns a value, do you have to explicitly typecast it in Java from Object into the desired type? Thanks, Mark -- You received this message because yo

Re: Calling Clojure from Java

2010-12-22 Thread Alex Osborne
Mark Engelberg writes: > Are there any examples available of creating a compiled > class/interface with deftype and defprotocol, and using these from > Java? It's pretty straightforward and works exactly how you might expect it to. Create a new project: $ lein new interop Define a type and

Re: Calling Clojure from Java

2010-12-22 Thread Meikel Brandmeyer
Hi, Am 22.12.2010 um 11:15 schrieb Mark Engelberg: > Are there any examples available of creating a compiled > class/interface with deftype and defprotocol, and using these from > Java? Protocols also define an interface which can be implemented by classes. For deftype this happens when you spe

Re: Calling Clojure from Java

2010-12-22 Thread Mark Engelberg
Are there any examples available of creating a compiled class/interface with deftype and defprotocol, and using these from Java? -- 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 po

Re: Calling Clojure from Java

2010-12-22 Thread Meikel Brandmeyer
Hi, Am 22.12.2010 um 10:56 schrieb Mark Engelberg: > On Wed, Dec 22, 2010 at 1:52 AM, Meikel Brandmeyer wrote: >> It is a little ugly, but works with any function, in particular static and >> protocol functions. If you want a less rough interface, you can still go the >> gen-class route from t

Re: Calling Clojure from Java

2010-12-22 Thread Laurent PETIT
2010/12/22 Mark Engelberg > On Wed, Dec 22, 2010 at 1:52 AM, Meikel Brandmeyer wrote: > > It is a little ugly, but works with any function, in particular static > and protocol functions. If you want a less rough interface, you can still go > the gen-class route from the article. But this will co

Re: Calling Clojure from Java

2010-12-22 Thread Laurent PETIT
2010/12/22 Meikel Brandmeyer > Hi, > > Am 22.12.2010 um 10:13 schrieb Mark Engelberg: > > > I'm trying to figure out how to bundle up some Clojure code into a jar > > to be accessed by someone in Java. > > > > My google search turned up this link: > > http://java.dzone.com/articles/java-clojure-i

Re: Calling Clojure from Java

2010-12-22 Thread Mark Engelberg
On Wed, Dec 22, 2010 at 1:52 AM, Meikel Brandmeyer wrote: > It is a little ugly, but works with any function, in particular static and > protocol functions. If you want a less rough interface, you can still go the > gen-class route from the article. But this will come at the cost of one level >

Re: Calling Clojure from Java

2010-12-22 Thread Meikel Brandmeyer
Hi, Am 22.12.2010 um 10:13 schrieb Mark Engelberg: > I'm trying to figure out how to bundle up some Clojure code into a jar > to be accessed by someone in Java. > > My google search turned up this link: > http://java.dzone.com/articles/java-clojure-interop-calling > which dates back to Clojure 1

Re: My first Clojure program: request for code review

2010-12-22 Thread Marek Kubica
Hi, Thanks for your review and your improvements (of course also to Justin, whose improvements are also useful). I'll try to merge them into some "optimal" solution :) On Tue, 21 Dec 2010 20:46:56 -0800 (PST) Benny Tsai wrote: > Hi Marek, > > Here's my tweaked version: > > (ns karma > (:use

Re: Mocking multimethods

2010-12-22 Thread Meikel Brandmeyer
Hi, maybe a different approach could be to use a richer datatype than a function, which carries both: the command and the undo command. (deftype Command [action undo]) Then you could do something like: (defn do-patch! [command args] (dosync (let [patch {:command command :args (vec args

Calling Clojure from Java

2010-12-22 Thread Mark Engelberg
I'm trying to figure out how to bundle up some Clojure code into a jar to be accessed by someone in Java. My google search turned up this link: http://java.dzone.com/articles/java-clojure-interop-calling which dates back to Clojure 1.1. Seems like a lot of changes have occurred since then -- stat

Re: Clojure, Parallel programming and Leslie Lamport

2010-12-22 Thread Konrad Hinsen
On 22 Dec 2010, at 09:28, Tim Daly wrote: Clojure works well for concurrency but does not really address the parallel question well. For that I've turned to MPI. I am working on using MPI from Clojure. That's a topic I am very interested in as well, although unfortunately I never find the ti

Clojure, Parallel programming and Leslie Lamport

2010-12-22 Thread Tim Daly
Clojure works well for concurrency but does not really address the parallel question well. For that I've turned to MPI. I am working on using MPI from Clojure. These are some links others might find interesting. The video interview with Leslie Lamport http://channel9.msdn.com/Shows/Going+Deep/E2