Re: Seeking advice on a safe way to mock/stub fns

2013-03-26 Thread Shantanu Kumar
Sorry, in the last illustration, the (binding [*deps* deps] ...) cannot be useful for Compojure route handlers because dynamic vars are bound at a thread-local level; you will probably have to `alter-var-root` it to some var and have the handlers use that static var instead. In the code I write

Re: Seeking advice on a safe way to mock/stub fns

2013-03-26 Thread Shantanu Kumar
On Wednesday, 27 March 2013 08:06:30 UTC+5:30, Leif wrote: > > Hi, Shantanu. > > Thanks for the suggestions. A couple thoughts: > > 1. Many times, I seem to stub or mock things that are scattered here and > there in the code, like things that send email or log metrics, etc. so > they are not

Re: Apply elements in a vector as arguments to function

2013-03-26 Thread Michael Klishin
2013/3/27 Jim - FooBar(); > aaa see? always check the docs first and the sources second (if > available)...I should have done that as well :) Definitely don't just check the sources and think it's something normal. Complain loudly to maintainers on this list that their documentation has gaps a

Re: Seeking advice on a safe way to mock/stub fns

2013-03-26 Thread Leif
Hi, Shantanu. Thanks for the suggestions. A couple thoughts: 1. Many times, I seem to stub or mock things that are scattered here and there in the code, like things that send email or log metrics, etc. so they are not really isolated (or isolatable??), but I still want to test that they get

Re: Seeking advice on a safe way to mock/stub fns

2013-03-26 Thread Leif
Hi, Allen. My own version of with-redefs? That *sounds* kind of hard. Could you keep an atom with the "original" bound value (the first one my-with-redefs sees, anyway) and then always roll back to that value? Something like that? Thanks, Leif On Monday, March 25, 2013 1:58:53 AM UTC-4, All

Re: (load "hello") can't see hello.clj in the current directory.

2013-03-26 Thread Leif
I works for me if I run 'lein repl' *outside* of a project. In that case, "" is on the classpath, so "." looks in the current directory. When you run 'lein repl' *inside* of a project, however, the top-level project directory is not on the classpath. "." in this case probably means "look in t

Re: (load "hello") can't see hello.clj in the current directory.

2013-03-26 Thread stephen jones
try (load-file "hello.clj") On Tuesday, March 26, 2013 9:25:43 AM UTC-7, MC Andre wrote: > > I tried setting *compile-path* to ".", but Clojure still can't find > hello.clj. > > Trace: > > $ cat hello.clj > (ns hello > (:gen-class)) > > (defn -main [& args] > (println "Hello World!\n")) > > $

Re: Sweet-expressions

2013-03-26 Thread Gary Verhaegen
Right now, Clojure is fighting its way to get to Java-like performance for numerics, and that involves emitting primitive numbers and operations whenever possible. I'm afraid that would be utterly incompatible with turning numbers into functions - that would be at least two levels of indirection (n

Re: Apply elements in a vector as arguments to function

2013-03-26 Thread Ryan
Well, I did check em but It wasn't clear to me that I could pass a vector; I thought that was only for aliasing. Oh well, it happens I guess :) Thanks again everybody! On Tuesday, March 26, 2013 10:30:48 PM UTC+2, Jim foo.bar wrote: > > aaa see? always check the docs first and the sources secon

[GSoC Idea] Program analysis suite, based on Rich Hickey's Codeq

2013-03-26 Thread Rich Morin
Category: Tooling Name: Program analysis suite, based on Rich Hickey's Codeq Brief explanation: Rich Hickey, inventor of Clojure and Datomic, created Codeq as a prototype framework for program analysis. It harvests multiple information sources (eg, Git metadata, source cod

Re: Apply elements in a vector as arguments to function

2013-03-26 Thread Jim - FooBar();
aaa see? always check the docs first and the sources second (if available)...I should have done that as well :) Jim On 26/03/13 20:28, Ryan wrote: Ah damn, you are right! Sorry if I wasted anyone's time :) At least I learned that apply was the way to go in my original post On Tuesday, March

Re: Apply elements in a vector as arguments to function

2013-03-26 Thread Ryan
Ah damn, you are right! Sorry if I wasted anyone's time :) At least I learned that apply was the way to go in my original post On Tuesday, March 26, 2013 10:23:10 PM UTC+2, Cedric Greevey wrote: > > The docs there seem to imply that fields takes a keyword or a vector, > rather than a keyword or

Re: Apply elements in a vector as arguments to function

2013-03-26 Thread Jim - FooBar();
;;from the website you linked (/fields/ [:firstname :first]:last :address.state) ;; you can alias a field using a vector of [field alias] Your vector argument should look like this: [[:firstname :first]:last :address.state] or like this (if you're not aliasing): [:firstname :last :

Re: Apply elements in a vector as arguments to function

2013-03-26 Thread Cedric Greevey
The docs there seem to imply that fields takes a keyword or a vector, rather than a keyword or keywords. Try just (fields fields-vector), without the "apply". On Tue, Mar 26, 2013 at 4:12 PM, Ryan wrote: > Thank you guys for your answer. apply was the first thing I used but I got > the followin

Re: Apply elements in a vector as arguments to function

2013-03-26 Thread Ryan
Thank you guys for your answer. apply was the first thing I used but I got the following error: java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to > clojure.lang.Associative and i thought i am not going the right way. What i am more specifically trying to do is this: http:/

Re: Apply elements in a vector as arguments to function

2013-03-26 Thread Jim - FooBar();
On 26/03/13 19:28, Ryan wrote: apply the elements of my vector as arguments to the function you said it yourself in your first post... :) 'apply' is what you're looking for! Jim -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this

Re: Apply elements in a vector as arguments to function

2013-03-26 Thread Alan Thompson
Essentially, apply just removes the parens (or brackets) from your list of args and creates the original function call: (apply + [1 2 3]) -> (+ 1 2 3) Alan Thompson On Tue, Mar 26, 2013 at 12:49 PM, Alan Thompson wrote: > Apply works for any number of args: > > (apply + [1 2 3 4 5]) > > He

Re: Apply elements in a vector as arguments to function

2013-03-26 Thread Max Penet
You are mistaken :) try: (apply str [:a :b :c]) (apply str [:a :b :c :d :e]) > (doc apply) - clojure.core/apply ([f args] [f x args] [f x y args] [f x y z args] [f a b c d & args]) Applies fn f to the argument list formed by prepending intervening arguments to args. nil

Re: Apply elements in a vector as arguments to function

2013-03-26 Thread Michael Klishin
2013/3/26 Ryan > Thanks Michael, but If i am not mistaken, your example only works with a > vector with two elements. What if we have an unknown number of vector > elements? > My apologies if that wasn't clear on my first post. > If your function's signature allows for & rest arguments, it will

Re: Apply elements in a vector as arguments to function

2013-03-26 Thread Alan Thompson
Apply works for any number of args: (apply + [1 2 3 4 5]) He just gave you an example inline function of 2 args since that was the original example. Alan Thompson On Tue, Mar 26, 2013 at 12:44 PM, Ryan wrote: > Thanks Michael, but If i am not mistaken, your example only works with a > vector

Re: Apply elements in a vector as arguments to function

2013-03-26 Thread Marko Topolnik
Have you tried (apply my-function [:foo :bar]) yet? Because *apply* is exactly what you are looking for; to make sure, read its docstring. On Tuesday, March 26, 2013 8:44:49 PM UTC+1, Ryan wrote: > > Thanks Michael, but If i am not mistaken, your example only works with a > vector with two eleme

Re: Apply elements in a vector as arguments to function

2013-03-26 Thread Ryan
Thanks Michael, but If i am not mistaken, your example only works with a vector with two elements. What if we have an unknown number of vector elements? My apologies if that wasn't clear on my first post. On Tuesday, March 26, 2013 9:38:55 PM UTC+2, Michael Klishin wrote: > > > 2013/3/26 Ryan >

Re: Apply elements in a vector as arguments to function

2013-03-26 Thread Michael Klishin
2013/3/26 Ryan > What i am trying to do is to apply the elements of my vector as arguments > to the function. How can I achieve this? user=> (apply (fn [a b] (println a b)) [:a :b]) :a :b nil -- MK http://github.com/michaelklishin http://twitter.com/michaelklishin -- -- You received this

Apply elements in a vector as arguments to function

2013-03-26 Thread Ryan
Hello all, I have been searching and searching on how to do this but I am failing miserably. I am trying to do a pretty simply thing actually. I have the following vector: [:foo :bar] and a function that takes keywords as arguments, like so: (my-function :foo :bar & more) What i am trying

Seeking help with the Leiningen Chocolatey package (Windows)

2013-03-26 Thread Michael Klishin
Folks who use Leiningen on Windows, Leiningen maintainers need a little bit of your help. The Chocolatey Leiningen package maintainer can no longer support it and is looking to pass things on: http://chocolatey.org/packages/leiningen If you are familiar with Chocolatey, consider helping him out.

Re: why am I hitting the 64k method limit on a var?

2013-03-26 Thread Marko Topolnik
On Tuesday, March 26, 2013 6:54:12 PM UTC+1, David Powell wrote: > > > On Tue, Mar 26, 2013 at 5:48 PM, larry google groups > > > wrote: > >> >> > I'd guess that this would be a pretty big map to run to over 64k though >> - though >> > I think Clojure has a single initialiser method that initi

Re: [ANN] Amazonica: Clojure client for the entire AWS api

2013-03-26 Thread Hugo Duncan
Michael Cohen writes: > Well, of course everything is handled via reflection, which has a cost. The > question is, can you afford the cost. Or can the cost be confined to compile time... > In general, I think most of the AWS > apis really aren't concerned with performance, e.g. EC2, and you'

Re: [ANN] Amazonica: Clojure client for the entire AWS api

2013-03-26 Thread Michael Cohen
Well, of course everything is handled via reflection, which has a cost. The question is, can you afford the cost. In general, I think most of the AWS apis really aren't concerned with performance, e.g. EC2, and you're not making (many) repeated calls. If you look at something like DynamoDB thou

Re: [ANN] Amazonica: Clojure client for the entire AWS api

2013-03-26 Thread Timothy Baldridge
I'm a bit concerned about all the reflection going on. Am I correct that the lib does dynamic dispatch at runtime based on both the arity and the number of arguments? The code looks like it would be painfully slow. Perhaps the hit is okay if I only want to make a dozen calls a second or so, but if

Re: [ANN] Amazonica: Clojure client for the entire AWS api

2013-03-26 Thread Michael Cohen
Thanks for the comments. I've made the suggested changes such that the AWS functions take an optional first parameter map of credentials. But I'm left wondering if it should not be required, and just do away with the stateful "defcredential" convenience. Thots? On Monday, March 25, 2013 6:29:

Re: why am I hitting the 64k method limit on a var?

2013-03-26 Thread David Powell
On Tue, Mar 26, 2013 at 5:48 PM, larry google groups < lawrencecloj...@gmail.com> wrote: > > > I'd guess that this would be a pretty big map to run to over 64k though > - though > > I think Clojure has a single initialiser method that initialises all > vars in the > > namespace, so it is tha total

Re: why am I hitting the 64k method limit on a var?

2013-03-26 Thread larry google groups
> I'd guess that this would be a pretty big map to run to over 64k though - though > I think Clojure has a single initialiser method that initialises all vars in the > namespace, so it is tha total that is important. It certainly seems as if it is the whole namespace that is being compiled.

Re: JIT Compiler crash on IBM JDK 6

2013-03-26 Thread Andy Fingerhut
On Tue, Mar 26, 2013 at 5:21 AM, Paudi Moriarty wrote: > > IBM JDK 6 is part of the clojure build matrix (though the last stable > build is from over a year ago: > http://build.clojure.org/job/clojure-test-matrix/jdk=IBM%20JDK%201.6/lastStableBuild/ > ) > I don't have any suggestions about the cr

Re: Sweet-expressions

2013-03-26 Thread david sheldrick
I don't like the idea of infix math as a reader macro. Yeah prefix is weird to read for complex expressions, but in such rare cases there are ordinary macros that let you do infix math. Use them. An interesting thought I had the other day regarding infix math: It would be possible for Clojure to

Re: JIT Compiler crash on IBM JDK 6

2013-03-26 Thread Paudi Moriarty
Thanks for that, I'll have a look. Think it was SR3 on x86_64 I tried. On Tuesday, 26 March 2013 16:09:43 UTC, Thomas wrote: > > > > On Tuesday, March 26, 2013 3:19:08 PM UTC, Paudi Moriarty wrote: >> >> Hi Thomas, >> >> This is occuring on every Linux and AIX version I've tried, SR9, SR11 and >>

Re: JIT Compiler crash on IBM JDK 6

2013-03-26 Thread Thomas
On Tuesday, March 26, 2013 3:19:08 PM UTC, Paudi Moriarty wrote: > > Hi Thomas, > > This is occuring on every Linux and AIX version I've tried, SR9, SR11 and > SR12. I tried Java 7 but it seems Clojure is very broken on IBM Java 7. > Getting ClassFormatErrors when building Clojure itself there!

Re: why am I hitting the 64k method limit on a var?

2013-03-26 Thread Marko Topolnik
On Tuesday, March 26, 2013 12:13:54 PM UTC+1, David Powell wrote: > > On Tue, Mar 26, 2013 at 10:40 AM, Marko Topolnik > > > wrote: > >> What exactly is getting compiled into a class here? Not the map itself, I >> believe; that wouldn't even cause this error. >> >> From general clues, the code

Re: JIT Compiler crash on IBM JDK 6

2013-03-26 Thread Paudi Moriarty
Hi Thomas, This is occuring on every Linux and AIX version I've tried, SR9, SR11 and SR12. I tried Java 7 but it seems Clojure is very broken on IBM Java 7. Getting ClassFormatErrors when building Clojure itself there! Paudi On Tuesday, 26 March 2013 14:38:44 UTC, Thomas wrote: > > Hi Paudi, >

Re: JIT Compiler crash on IBM JDK 6

2013-03-26 Thread Thomas
Hi Paudi, Which particular version of the IBM JDK are you running (java -version) and have you checked if you are running the very latest version? Thomas -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to cloj

GSoC 2013: Only three days left to submit project ideas

2013-03-26 Thread Daniel Solano Gómez
Hello, all, There are just three days left to prepare our application for GSoC 2013. Although we have a number of really good ideas up on our Project Ideas page , we really need to do a lot more in order to strengthen our application. By sub

Re: Clojure/West 2013 videos?

2013-03-26 Thread Rick Beerendonk
Alex, you are doing a wonderful job with the videos. InfoQ is helping us all by making a business out of quality videos. From experience, I know there are always people wanting things quicker and cheaper. I bet the same complains will be here if the videos are releases in half the time. Of cour

Re: Accessing a resource inside a jar

2013-03-26 Thread Clinton N. Dreisbach
John, That appears to be working. Thanks! -- Clinton On Tuesday, March 26, 2013 12:04:38 AM UTC-4, John Hume wrote: > > It looks like MimetypesFileTypeMap wants a path to a plain file. I can't > try this right now, but I think you want the constructor that takes an > InputStream. Something lik

JIT Compiler crash on IBM JDK 6

2013-03-26 Thread Paudi Moriarty
Hi, I'm hitting a JIT compiler bug in IBM JDK 6 with the following code (forcing JIT compilation using -Xjit:count=0): (defprotocol FooProtocol (do-something [x])) (def foo (reify FooProtocol (do-something [this] (locking this (println "XXX") (do-s

Re: why am I hitting the 64k method limit on a var?

2013-03-26 Thread David Powell
On Tue, Mar 26, 2013 at 10:40 AM, Marko Topolnik wrote: > What exactly is getting compiled into a class here? Not the map itself, I > believe; that wouldn't even cause this error. > > From general clues, the code that builds your config map is being compiled > into a method. Without AOT compilatio

Re: why am I hitting the 64k method limit on a var?

2013-03-26 Thread Marko Topolnik
What exactly is getting compiled into a class here? Not the map itself, I believe; that wouldn't even cause this error. >From general clues, the code that builds your config map is being compiled into a method. Without AOT compilation this shouldn't be happening, but I'm surprised it's happenin

Re: Which is the most idiomatic way to go

2013-03-26 Thread Ryan
Ah! Got what you mean, thanks a lot :) On Tuesday, March 26, 2013 3:52:39 AM UTC+2, Herwig Hochleitner wrote: > > 2013/3/25 Ryan > > >> Thanks for your input Herwig. >> >> When talking to a database, there might already be record and >>> list-of-records interface, for step 2. >> >> >> I didn't fu