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

2013-03-24 Thread Allen Rohner
I've also run into the problem. You could write your own version of with-redefs (it's not that hard). In your case, it sounds like you're not running tests in parallel in the same process, so could you work around it by waiting for your app to finish initializing before running tests? Allen

Re: Clojure/West 2013 videos?

2013-03-24 Thread Alan Busby
On Mon, Mar 25, 2013 at 12:24 PM, Rich Morin wrote: > I can wait a bit for the editing; > clean results are more important than saving a month or so. > I wouldn't say anything if it was only a month, it's actually closer to 3-7 months after the conference though. Clojure West 2012 was held Mar

Re: Clojure/West 2013 videos?

2013-03-24 Thread Michael Klishin
2013/3/25 Cedric Greevey > A lot of computers are shipping with free no-frills video editing software > these days that probably suffices for this. Do those computers also ship with a person who has a lot of experience editing video and audio? It takes more than a hour to edit a 40-45 minute l

Re: Clojure/West 2013 videos?

2013-03-24 Thread Cedric Greevey
On Mon, Mar 25, 2013 at 1:16 AM, Sean Grove wrote: > I'm sure that having nice videos (which have all been awesome) aren't > cheap, nor are they easy to produce. It's unfair to trivialize the > production and editing of high-quality material. > We aren't talking Hollywood blockbusters here. A st

Re: Clojure/West 2013 videos?

2013-03-24 Thread Sean Grove
I'm sure that having nice videos (which have all been awesome) aren't cheap, nor are they easy to produce. It's unfair to trivialize the production and editing of high-quality material. That said, a thought I've been surprised no one has suggested is a crowdtilt/kickstarter-style campaign to get t

Re: Clojure/West 2013 videos?

2013-03-24 Thread Cedric Greevey
On Sun, Mar 24, 2013 at 11:24 PM, Rich Morin wrote: > On Mar 24, 2013, at 18:44, Cedric Greevey wrote: > > Where are these costs coming from? ... > > To get professional results, you need more than a camera > on a tripod. For example, someone has to: > > * keep the camera on the speaker > Th

Re: "Decompiling" clojure functions

2013-03-24 Thread Michael Klishin
2013/3/25 JvJ > Is there any way to "open up" a function and look at the source code that > made it? I know there is some source code in the documentation of certain > functions, but I'm looking for a way to view the structures that make up > the code. http://clojuredocs.org/clojure_core/cloju

Re: Clojure/West 2013 videos?

2013-03-24 Thread Rich Morin
On Mar 24, 2013, at 18:44, Cedric Greevey wrote: > Where are these costs coming from? ... To get professional results, you need more than a camera on a tripod. For example, someone has to: * keep the camera on the speaker * get clean copies of the slides * merge the slides with the vide

Re: Concurrency and custom types.

2013-03-24 Thread Cedric Greevey
On Sun, Mar 24, 2013 at 6:59 PM, Andy Fingerhut wrote: > > > On Sun, Mar 24, 2013 at 11:04 AM, Jim - FooBar(); wrote: > >> On 24/03/13 17:49, Shantanu Kumar wrote: >> >>> In this case, making the type immutable is probably encouraged but not >>> mandatory >>> >> >> yes true, it's not enforced or a

Re: Clojure/West 2013 videos?

2013-03-24 Thread Cedric Greevey
On Sun, Mar 24, 2013 at 7:23 PM, Alex Miller wrote: > I have done a fair amount of polling on this for Strange Loop and it's > problematic. > > - there are a small number of interested people which thus requires high > per-person prices for videos (higher than you think - Strata video > compilati

Re: Which is the most idiomatic way to go

2013-03-24 Thread Leif
I'm totally in favor of your alternate approach, for these reasons: 1. As you noted, it's easier to test. 2. I separates your data processing from the side-effects, which lets you implement batching, switch to another DB, etc. without touching the data processing code. So I would trust your i

Re: Redefinition of datatypes

2013-03-24 Thread Ambrose Bonnaire-Sergeant
Hi Stuart, I think the problem is slightly deeper with core.typed. I use `derive` to define a common supertype for several defrecords, which is the source of the original (Filter? +) assertion error. Filter? is defined (def Filter ::filter) (defn Filter? [a] (isa? (class a) Filter)) This ends

Seeking advice on a safe way to mock/stub fns

2013-03-24 Thread Leif
Hello, fellow Clojurians. One problem I've run into when stubbing fns is that with-redefs doesn't play well with concurrency. E.g. http://clojuredocs.org/clojure_core/clojure.core/with-redefs#example_994 The problem arises because, quoting with-redef's docstring, "These temporary changes wil

Re: Redefinition of datatypes

2013-03-24 Thread Stuart Sierra
Ah yes, the joys of AOT-compilation and static initializers. I know them well. Strange things happen with AOT-compilation. Classes get loaded in a different order, or get loaded by different classloaders. Maybe someday we can figure it all out. Try replacing that with `instance?` as you say. (I

Re: defrecord and map

2013-03-24 Thread Stephen Compall
On Sun, 2013-03-24 at 10:32 -0700, N8Dawgrr wrote: > Is there a mechanism in Clojure to say apply f to all the values of a > record and return me a new record of the same type? You can add one via the wonderful `into' function: (into your-record (map (fn [k v] [k (f v)]) your-record)) -- Steph

Re: Clojure/West 2013 videos?

2013-03-24 Thread Alex Miller
I have done a fair amount of polling on this for Strange Loop and it's problematic. - there are a small number of interested people which thus requires high per-person prices for videos (higher than you think - Strata video compilation is $400 for example) - high prices further reduce the numbe

Re: Concurrency and custom types.

2013-03-24 Thread Andy Fingerhut
On Sun, Mar 24, 2013 at 11:04 AM, Jim - FooBar(); wrote: > On 24/03/13 17:49, Shantanu Kumar wrote: > >> In this case, making the type immutable is probably encouraged but not >> mandatory >> > > yes true, it's not enforced or anything like that, but I'd say it is more > than just 'encouraged'...

Re: Debug prints don't execute on multimethod dispatch functions

2013-03-24 Thread George Oliver
On Sunday, March 24, 2013 3:01:53 PM UTC-7, George Oliver wrote: > > > > Not sure, but is it possible you're running afoul of a redefined defmulti > not overriding the original defmulti in the REPL? Try clearing the defmulti > with a (def dispatch-fn nil) and then reloading the defmulti? > Sor

Re: Debug prints don't execute on multimethod dispatch functions

2013-03-24 Thread George Oliver
On Sunday, March 24, 2013 12:49:40 PM UTC-7, JvJ wrote: > > > I started using the meta-type function for dispatch, but then started > using debug-switch. It actually works fine, running the appropriate > version of the method, but the println doesn't execute. Does anyone know > why? > > Not

Re: Macro for bailout-style programming

2013-03-24 Thread Gary Johnson
+1 for some-> and some->>. I use this all the time in my coding. They used to be -?> and -?>> in clojure.core.incubator, so I'm extremely happy that they finally made their way into core proper. On Saturday, March 23, 2013 7:25:00 PM UTC-4, Evan Gamble wrote: > > The let? macro addresses such s

Re: "Decompiling" clojure functions

2013-03-24 Thread JvJ
By the way, with-merge-meta keeps existing metadata and merges it with a new map, if you haven't figured that out. On Sunday, 24 March 2013 17:25:10 UTC-4, JvJ wrote: > > Is there any way to "open up" a function and look at the source code that > made it? I know there is some source code in the

"Decompiling" clojure functions

2013-03-24 Thread JvJ
Is there any way to "open up" a function and look at the source code that made it? I know there is some source code in the documentation of certain functions, but I'm looking for a way to view the structures that make up the code. As a kind of work around, I made a macro called M> (shown below

Re: In Emacs Org mode, how to round-trip Clojure code edits?

2013-03-24 Thread Moritz Ulrich
Just a shot in the dark; try: #+BEGIN_SRC clojure (defun org-xor (a b) "Exclusive or." (if a (not b) b)) #+END_SRC On Sat, Mar 23, 2013 at 10:27 PM, Matching Socks wrote: > I've got clojure-mode and nrepl installed, but I skipped Slime. From the > org-mode s

Re: Concurrency and custom types.

2013-03-24 Thread Richard Elliott
thanks guys. On Sunday, 24 March 2013 19:27:59 UTC, Shantanu Kumar wrote: > > > > On Sunday, 24 March 2013 23:34:38 UTC+5:30, Jim foo.bar wrote: >> >> On 24/03/13 17:49, Shantanu Kumar wrote: >> > In this case, making the type immutable is probably encouraged but not >> > mandatory >> >> yes tr

Debug prints don't execute on multimethod dispatch functions

2013-03-24 Thread JvJ
I'm having a problem with some multimethods, so I'm trying to create debug versions of the dispatch functions which have debug prints in them. However, the prints aren't executing. Here's an example: (defn meta-type "Gets the metadata type." [o] (when-let [m (meta o)] (:type m))) (d

Re: Concurrency and custom types.

2013-03-24 Thread Shantanu Kumar
On Sunday, 24 March 2013 23:34:38 UTC+5:30, Jim foo.bar wrote: > > On 24/03/13 17:49, Shantanu Kumar wrote: > > In this case, making the type immutable is probably encouraged but not > > mandatory > > yes true, it's not enforced or anything like that, but I'd say it is > more than just 'encou

Re: Is it possible to set breakpoint using nrepl-ritz?

2013-03-24 Thread Prasad Chalasani
I have exactly the same problem. On Saturday, March 16, 2013 11:46:00 AM UTC-4, Warren Lynn wrote: > > > Could you create an issue for this. >> >> >> > Just did that. > > Even with "M-x nrepl-ritz-break-on-exception" (and adding an (throw ...) > in the code), it still does not work for me. Just

Re: Exception propagation design in Clojure web APIs.

2013-03-24 Thread Julien Dreux
For anyone looking to do something similar (i.e. using exception control flow for handling request errors & validation), I found the slingshot library invaluable for enhanced try and throw leveraging Clojure. Going with 'native' try/throw was becoming ni

Re: Concurrency and custom types.

2013-03-24 Thread Jim - FooBar();
On 24/03/13 17:49, Shantanu Kumar wrote: In this case, making the type immutable is probably encouraged but not mandatory yes true, it's not enforced or anything like that, but I'd say it is more than just 'encouraged'... what would be the point of using clojure's reference types with somethi

Re: Concurrency and custom types.

2013-03-24 Thread Shantanu Kumar
On Sunday, 24 March 2013 22:04:46 UTC+5:30, Richard Elliott wrote: > > Hi, > > If i create an immutable type in java and use an instance of it from > clojure, can I wrap it in an atom and benefit from the concurrency > semantics of swap! etc. > In this case, making the type immutable is probab

Re: ring reloading: IllegalStateException: identity already refers to: #'cemerick.friend/identity in namespace:

2013-03-24 Thread Nelson Morris
Ack, I meant :require. In your snippet you mention (:use [cemerick.friend :as friend]). I meant that you might want (:require [cemerick.friend :as friend]) instead. I think http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html has been floatin

defrecord and map

2013-03-24 Thread N8Dawgrr
Hi, I'm transforming a recursive form structure to an equivalent structure represented by Clojure records. I want polymorphic dispatch across my newly created structure of records. I also want to be able to apply a function to transform the structure of records, in much the same way as say clo

Re: Concurrency and custom types.

2013-03-24 Thread Jim - FooBar();
of course you can... however be careful of what you mean immutable in Java. Declaring fields as final doesn't make them immutable unless they point to something immutable (a value). if they do, make sure you override .equals() appropriately and you're good to go... :) Jim On 24/03/13 16:34

Concurrency and custom types.

2013-03-24 Thread Richard Elliott
Hi, If i create an immutable type in java and use an instance of it from clojure, can I wrap it in an atom and benefit from the concurrency semantics of swap! etc. Cheers Richard -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this

Re: ring reloading: IllegalStateException: identity already refers to: #'cemerick.friend/identity in namespace:

2013-03-24 Thread Assen Kolov
Thank you Nelson, Can you please explain exactly what refer you mean? In the meanwhile [:refer-clojure :exclude [identity]] fixed the problem. Regards, Assen On Sunday, 24 March 2013 16:43:39 UTC+1, Nelson Morris wrote: > > > In the application, I have :use [cemerick.friend :as friend], whe

Re: ring reloading: IllegalStateException: identity already refers to: #'cemerick.friend/identity in namespace:

2013-03-24 Thread Nelson Morris
> In the application, I have :use [cemerick.friend :as friend], where indeed > a identity function is defined. I think you want :refer here. -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroup

Re: Coding while running the program

2013-03-24 Thread Antoine Noo
Hello, You can use var as references. example: (def A 1) (def B (var A)) (def A 12) @B give you 12 if A is a function (@B) and (B) execute A's function. 2013/3/24 Oskar Kvist > George Oliver: I actually tried penumbra (the graphics lib he uses in the > tetris video) and was able to code whil

ring reloading: IllegalStateException: identity already refers to: #'cemerick.friend/identity in namespace:

2013-03-24 Thread Assen Kolov
Hi all, I have a problem running cemerick/friend with lein ring. When I start the application with lein ring server-headless, I just get a warning (WARNING: identity already refers to: #'clojure.core/identity in namespace: civi.core, being replaced by: #'cemerick.friend/identity) but am able to

Re: In Emacs Org mode, how to round-trip Clojure code edits?

2013-03-24 Thread Hans Engel
I found the same issue on Emacs 24.3.1 with Org 7.9.4 (installed via ELPA) and clojure-mode 2.0.0. When opening a Clojure snippet in Org mode for editing, Org tried to call an apparently undefined function `org-no-popup`. When this failed, it left the source code buffer in fundamental mode, wher

Re: strange behaviour

2013-03-24 Thread Jim - FooBar();
ooo I found this: http://stackoverflow.com/questions/10565874/non-linear-slowdown-creating-a-lazy-seq-in-clojure I did not post this but this guy came up with the same solution... Jim ps: the 'partition' solution does seem much better... On 24/03/13 14:17, Jim - FooBar(); wrote: i'm getting s

Re: strange behaviour

2013-03-24 Thread Jim - FooBar();
i'm getting slightly paranoid now...let's forget about my code for a second...paste this into your repl: *;;using the original ngrams** (defrecord DUMMY [token tag]) (def Dpairs (doall (repeat 3 (DUMMY. "them" "PRO" ;them->pronoun (def Dtags (mapv :tag Dpairs)) (def tag-ngrams (doall (

Re: strange behaviour

2013-03-24 Thread Jim - FooBar();
wow! this is even stranger now!!! I removed the call to count from ngrams* and now the same thing happens but all 4 cpus are busy!!! I don't understand... Jim On 24/03/13 13:54, Marko Topolnik wrote: May or may not be related, but calling /count/ on a lazy sequence eagerly consumes the entir

Re: strange behaviour

2013-03-24 Thread Marko Topolnik
May or may not be related, but calling *count* on a lazy sequence eagerly consumes the entire sequence. On Sunday, March 24, 2013 2:35:35 PM UTC+1, Jim foo.bar wrote: > > the operation is 'ngrams*' which doesn't care about what objects it > finds in the seq...Typically you'd have characters or

Re: strange behaviour

2013-03-24 Thread Jim - FooBar();
in other words, I can lose the 'doall' and do this: =>(def ntt-pairs (ngrams* tt-pairs 2)) #'hotel_nlp.algorithms.viterbi/ntt-pairs => (first ntt-pairs) (#hotel_nlp.algorithms.viterbi.TokenTagPair{:token "The", :tag "DET"} #hotel_nlp.algorithms.viterbi.TokenTagPair{:token "Fulton", :tag "NP"})

Re: strange behaviour

2013-03-24 Thread Jim - FooBar();
the operation is 'ngrams*' which doesn't care about what objects it finds in the seq...Typically you'd have characters or word ngrams but that doesn't mean you can't have any type of object...it simply doesn't care... (defn ngrams* "Create ngrams from a seq s. Pass a single string for chara

Re: strange behaviour

2013-03-24 Thread Marko Topolnik
What do you mean by "performing the same operation"? How can you perform the same operation on completely different objects? Do you mean that you don't have the exact same *ngrams** in the first and second case? On Sunday, March 24, 2013 1:45:37 PM UTC+1, Jim foo.bar wrote: > > Hi everyone, > >

Re: LoL which style for Clojure

2013-03-24 Thread Marko Topolnik
On Sunday, March 24, 2013 10:53:28 AM UTC+1, bsmith.occs wrote: > Way back when I started with Clojure i was doing this: > > (let [constant-data (something-expensive)] > (defn my-fn [x] > (do-something-with x constant-data))) > > But was advised instead to do this: > > (def my-fn > (let [c

Re: Is it possible to set breakpoint using nrepl-ritz?

2013-03-24 Thread Hugo Duncan
intronic writes: >> >> > Is it possible to set breakpoint using nrepl-ritz? >> >> It is using the latest development code (C-c C-x C-b on the line to >> break at). A release should be out containing this in the next few >> days. >> > > Can you explain how to use the latest dev code? > > Look

strange behaviour

2013-03-24 Thread Jim - FooBar();
Hi everyone, I'm experiencing some odd behaviour that I cannot justify so I thought someone smarter can help here... I'm reading in a file with 39,7226 lines, each one containing a token-tag pair (e.g. The/DET). This gives me 39,7226 fully-realized TokenTagPair objects (records-> TokenTagPai

Re: [ANN] Javelin, spreadsheet-like FRP for ClojureScript

2013-03-24 Thread Hank
Hi Alan, I'm looking forward to viewing your Clojure/West talk as soon as it comes out on video. In the meantime, I don't think javelin qualifies as "functional reactive". It is just "reactive". State like this: https://github.com/tailrecursion/javelin/blob/master/src/cljs/tailrecursion/javelin

Re: LoL which style for Clojure

2013-03-24 Thread Matching Socks
Doug Hoyte's book "Let Over Lambda—50 Years of Lisp" devotes its very title to the technique of (let...(fn...)). On Friday, March 22, 2013 2:59:43 PM UTC-4, jamieorc wrote: > > Curious which style is preferred in Clojure and why: > > (defn f1 [] > (let [x {:foo 1 :bar 2 :baz 3}] > (keys

Which is the most idiomatic way to go

2013-03-24 Thread Ryan
Hello all, I am trying to figure out which is the most idiomatic way to go in a project I am doing. I've noticed the following pattern in my code and I started wondering if there is a more clojurish approach to go with it. For the shake of readability and simplicity, I will provide a pseudo-cod

Re: Coding while running the program

2013-03-24 Thread Oskar Kvist
George Oliver: I actually tried penumbra (the graphics lib he uses in the tetris video) and was able to code while running the program. But penumbra is missing some features I would like. *Adrian*: Are you sure? I think Minecraft uses LWJGL, which is just a library of OpenGL bindings plus some

Re: Is it possible to set breakpoint using nrepl-ritz?

2013-03-24 Thread intronic
> > > Is it possible to set breakpoint using nrepl-ritz? > > It is using the latest development code (C-c C-x C-b on the line to > break at). A release should be out containing this in the next few > days. > Can you explain how to use the latest dev code? Looking at project.clj files on gi

Re: let-timed macro...any suggestions/corrections?

2013-03-24 Thread Jim - FooBar();
On 24/03/13 03:00, Stephen Compall wrote: This expression should evaluate to 12. Nice catch! This one does :) (defmacro let-timed [bindings & body] (let [parts (partition 2 bindings) names (map first parts) results (map #(list 'clojure.core/time (second %)) parts)]

Re: LoL which style for Clojure

2013-03-24 Thread Ben Smith-Mannschott
Way back when I started with Clojure i was doing this: (let [constant-data (something-expensive)] (defn my-fn [x] (do-something-with x constant-data))) But was advised instead to do this: (def my-fn (let [constant-data (something-expensive)] (fn [x] (do-something-with x constan

[ANN] cfg - Manage your options.

2013-03-24 Thread david sheldrick
I wrote this thing. It manages your options. I suppose it's pretty useful if you've got a whole bunch of the darn things to keep track of like I have. Go here: https://github.com/ds300/cfg Yeah, there are a bajillion of these already, but, like, mine is definitely way better *seriously guys*.*