Re: Accessing JSON Array data in Clojure

2013-05-10 Thread Michael Klishin
2013/5/10 Bryan Henderson bryan.d.hender...@gmail.com What map would be defined for the first argument with the given code? It seems like how it is set up, it is grabbing information straight from the JSON data without a map defined. Parsed JSON The 'format-forecast' definition takes

Re: Accessing JSON Array data in Clojure

2013-05-10 Thread Thomas Heller
Hey, I only glanced over the discussion, but I think you have a type problem. Keyword vs. Strings to be precise, the JSON data you pasted will not convert to keyword keys by default I think. So instead of (core/get-in forecast [:dayPrecipitation :temp]) try (core/get-in forecast

Re: [ANN] Himilsbach 0.0.1 is released

2013-05-10 Thread Jan Stępień
W dniu poniedziałek, 6 maja 2013 05:12:37 UTC+2 użytkownik Ben Mabey napisał: On Sun May 5 18:31:59 2013, Mikera wrote: On Tuesday, 30 April 2013 04:12:14 UTC+8, Jan Stępień wrote: Dear Clojurians, I'm very happy to announce Himilsbach 0.0.1. Himilsbach is a tiny actor

Re: Struggling with encapsulation

2013-05-10 Thread Colin Yates
Hi James - thanks for your response. I am still trying to wrap my head around this as I cannot agree. To re-frame, woobly allows you to add a job. The internal implementation of this is that it is decorates that job and puts the *decorated job* onto an internal LBQ. The implementation also

Re: Struggling with encapsulation

2013-05-10 Thread Korny Sietsma
I would generally handle this sort of encapsulation at the namespace level. Put (create-woobly) and (add-job) and all the other woobly-related functions into a woobly namespace. Also add any functions that access info from a woobly bag-o-state, or mutate a woobly to make a woobly-with-extras.

Re: Struggling with encapsulation

2013-05-10 Thread Colin Yates
Thanks Korny. Ok, the over-ridding theme seems to be: expose state, even if it is dangerous, but expect consumers to 'do the right thing' and read the documentation. I can see that. I guess I have worked (and to be honest, been guilty myself) with too many people who don't read the

Loop run until a Clojure Agent send-off is complete

2013-05-10 Thread Kelker Ryan
I would like to share a library that allows for bodies of code to loop run until a Clojure Agent send-off is complete. https://github.com/runexec/hollywood#how  -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Not using dependency injection - how do I share services around?

2013-05-10 Thread Colin Yates
(newbie, getting better each day!) I assume we all know DI. Through the use of a central registry I can register a service (a bean in a Spring bean factory for example). I also define consumers of that service in the same registry passing in the configured *instance* of that service. In

Re: Not using dependency injection - how do I share services around?

2013-05-10 Thread Chris Ford
A good question. One way is to use partial application to bake the data source into a fn: (def read (partial read-from-db *data-source*)) On 10 May 2013 14:04, Colin Yates colin.ya...@gmail.com wrote: (newbie, getting better each day!) I assume we all know DI. Through the use of a central

Re: Struggling with encapsulation

2013-05-10 Thread John D. Hume
I agree with the advice you've gotten, but since no one has mentioned it, I wanted to point out that you can have encapsulation w/o protocols with something like this. Assume a queue is your only state and `add` and `clear` are your private fns that take a queue as first argument. (defn

Re: Struggling with encapsulation

2013-05-10 Thread Colin Yates
Thanks John. To be explicit - the add method shouldn't be private - it is the only way users should add to the queue. I think this is what you meant but you wrote ..and `add` and `clear` are your private fns... Again, this paradigm shift of 'trust your users' is unfortunately alien to me based

Re: Struggling with encapsulation

2013-05-10 Thread John D. Hume
The add method that you partially apply in new-scheduler should be private, because a user can't supply the first argument it expects. You might do something like this. (defn- add* [queue item] (...)) (defn add [scheduler item] ((scheduler :add) item)) (defn new-scheduler [] (let [queue

Re: Struggling with encapsulation

2013-05-10 Thread James Reeves
On 10 May 2013 11:32, Colin Yates colin.ya...@gmail.com wrote: And please don't think I am making the 'code should stop bad programmers doing the wrong thing' argument, I'm not (been there, lost). I just know that if I released a scheduler library and the main construct was a map containing

Re: Not using dependency injection - how do I share services around?

2013-05-10 Thread Ben Mabey
Hi Colin, On 5/10/13 5:04 AM, Colin Yates wrote: 1) to use (defonce *data-source*...) so that every body who requires that ns gets the same instance? While this has been done I view this as an antipattern. The big problem with this approach is that you now can only have a single

Re: Struggling with encapsulation

2013-05-10 Thread Colin Yates
On 10 May 2013 14:10, James Reeves ja...@booleanknot.com wrote: Have you tried it? :) I've authored about 40 Clojure libraries over 5 years, some with data structures with internal components. The number of times someone has said I did X to this internal data and it broke is exactly zero.

Re: Not using dependency injection - how do I share services around?

2013-05-10 Thread Colin Yates
Thanks both - some good suggestions. After years of Java I am loving how 'symmetrical' everything is in Clojure (I guess in Lisp). Thanks for the library references. On 10 May 2013 14:14, Ben Mabey b...@benmabey.com wrote: Hi Colin, On 5/10/13 5:04 AM, Colin Yates wrote: 1) to use

Re: ANN: kits 1.5.1 - some of Runa's core utilities

2013-05-10 Thread John D. Hume
On Thu, May 9, 2013 at 7:15 PM, Dave Sann daves...@gmail.com wrote: There are several projects that provide a bunch of base level/common functions and extensions (similar to those here) beyond core Clojure. And I am sure that many people have their own collection of useful utilities like

Re: Struggling with encapsulation

2013-05-10 Thread Jim - FooBar();
On 10/05/13 14:20, Colin Yates wrote: This is all about changing my mindset from 15-odd years of Java dev by learning from others, so let's give it a go. Years of enterprise Java dev have gotten their cynical, 'data is precious and should be hidden away', 'other devs will do the wrong thing'

Re: Struggling with encapsulation

2013-05-10 Thread Colin Yates
I get your point, but Java's LinkedBlockingQueue is mutable. Of course, I should replace it with a plain sequence or Clojure's persistent queue but I really want the blocking semantics. That's tomorrow's job :). On 10 May 2013 15:37, Jim - FooBar(); jimpil1...@gmail.com wrote: On 10/05/13

Re: Parallel code execution in ClojureScript?

2013-05-10 Thread Ben Mabey
On 5/7/13 3:39 PM, Ghassan Ayesh wrote: Hi: In Javascript language, and while the language is inherently functional, Javascript's *implementation* until now, does not support parallel code execution against available CPU cores, unlike Erlang for example or Clojure on JVM, so I am thinking

Re: emacs - how to wean me off the family of Java IDEs

2013-05-10 Thread Eric S Fraga
Kendall Shaw ks...@kendallshaw.com writes: [...] I spent years with the beginnings of carpal tunnel syndrome and tried all sorts of changes, including using both hands. But, finally, I started using viper mode (vi key bindings) and I have had no carpal tunnel symptoms for 10 years. +1. I

Re: Clojure/Script pr-str/read-string roundtrip differences

2013-05-10 Thread Brian Jenkins
Doh! I was running 0.0-1586 instead of 0.0-1798 Brian On Monday, January 7, 2013 1:13:30 AM UTC+1, Thomas Heller wrote: Hey, I'm writing a Clojure Webapp with a CLJS Frontend and expected to be able to cljs.reader/read-string everything I pr-str'd on the CLJ side. That however does not

ANN: Alia Hayt 1.0.0 - Cassandra CQL3 Client and Query DSL

2013-05-10 Thread Max Penet
Hayt [1] is a CQL3 DSL allowing to compose queries from clojure functions and/or maps. Alia [2] is a full featured Cassandra client built on top of DataStax newly released java-driver [3] with a simple, yet powerful API and query DSL (Hayt). Detailed announcement: http://bit.ly/17a0zfQ [1]

Re: Clojure/West 2013 videos?

2013-05-10 Thread Geraldo Lopes de Souza
Clojure west videos are going to be released at the break for lunch of the armagedon battle. I hope to live until there :) Have a nice weekend guys ! On Thursday, March 21, 2013 1:08:48 PM UTC-3, John Gabriele wrote: Are there any videos available of the talks recently given at

Re: Clojure/Script pr-str/read-string roundtrip differences

2013-05-10 Thread David Nolen
I believe 0.0-1806 is the latest. On Fri, May 10, 2013 at 12:35 PM, Brian Jenkins bonky...@gmail.com wrote: Doh! I was running 0.0-1586 instead of 0.0-1798 Brian On Monday, January 7, 2013 1:13:30 AM UTC+1, Thomas Heller wrote: Hey, I'm writing a Clojure Webapp with a CLJS Frontend

Re: Not using dependency injection - how do I share services around?

2013-05-10 Thread Timo Mihaljov
On 10.05.2013 14:04, Colin Yates wrote: 2) to provide a 'get-ds' accessor which returns a new instance and rely on passing that service along to every function that needs it? For what it's worth, some people in the OO community, most notably Nat Pryce and Steve Freeman of Growing

Re: Lisp In Summer Projects

2013-05-10 Thread Plínio Balduino
Or sticks, t-shirts, whatever. I would do it just for fun. On Fri, May 10, 2013 at 2:18 AM, Terje Norderhaug te...@in-progress.com wrote: I suggest allowing participants from the listed countries, but give an eventual prize to a charity of choice to avoid a cash payment. On Thu, May 9, 2013

Re: Struggling with encapsulation

2013-05-10 Thread Timo Mihaljov
On 10.05.2013 14:44, John D. Hume wrote: Assume a queue is your only state and `add` and `clear` are your private fns that take a queue as first argument. (defn new-scheduler [] (let [queue (...)] {:add (partial add queue) :clear (partial clear queue)})) There are several

Re: Not using dependency injection - how do I share services around?

2013-05-10 Thread Colin Yates
Thanks Timo; Interesting links. Loving Clojure, but boy is it challenging the stuff I have been doing for the past how-ever many years :). On 10 May 2013 20:14, Timo Mihaljov t...@mihaljov.info wrote: On 10.05.2013 14:04, Colin Yates wrote: 2) to provide a 'get-ds' accessor which returns a

Re: Quick question on protocols

2013-05-10 Thread Stuart Sierra
When you extend a protocol to multiple Java interfaces / abstract classes, then call the methods on an instance which implements/extends more than one of those, the result is *undefined*. The problem is that this permits multiple inheritance of concrete behavior, the reason Java doesn't allow

Re: Quick question on protocols

2013-05-10 Thread Alan Malloy
Even when the interface and class you've extended them to are related by inheritance? I thought the most-derived implementation was chosen, and only when there's a tie like a class that implements two unrelated interfaces, both of which have had the protocol extended to them. If it were

Re: Quick question on protocols

2013-05-10 Thread David Nolen
It was my impression that extending to Object is handled as a special case - much like extend-type default in ClojureScript. On Fri, May 10, 2013 at 6:06 PM, Alan Malloy a...@malloys.org wrote: Even when the interface and class you've extended them to are related by inheritance? I thought the

test.generative war stories / improvements

2013-05-10 Thread Paul deGrandis
Hi all, I'm looking for feedback from people who have used test.generative for their own projects. Specifically I'm looking for: * things that bugged you or got in your way * changes to signatures/args/function names/interfaces * things you really wanted test.generative to do, but couldn't

Re: Quick question on protocols

2013-05-10 Thread Alan Malloy
Object is a little special, yes, so it was a bad example for me to use. But the code used for deciding which protocol implementation to use is pretty straightforwardhttps://github.com/clojure/clojure/blob/c0b81aa9d7ef30a5c252367c162bf7fb410ea4d7/src/clj/clojure/core_deftype.clj#L483-L502 .

Re: Not using dependency injection - how do I share services around?

2013-05-10 Thread Korny Sietsma
It's interesting to note that clojure.java.jdbc used to use our first option - they had a dynamically bound var *db* that you assigned using the (with-connection) macro. As of version 0.0.3 this has been deprecated in favour of something like your second option - now you pass an explicit db

Untangling Compilation External Libs: Clojurescript - Javascript

2013-05-10 Thread Timothy Washington
Hi all, I'm trying to suss out some problems I'm encountering when compiling Clojurescript, down to Javascript. I'm using i) a 3rd-party charting library (highcharts.com), and ii) using cljsbuild with :optimizations :whitespace ( :simple doesn't make a difference). 1. Clojurescript in

Re: Untangling Compilation External Libs: Clojurescript - Javascript

2013-05-10 Thread David Nolen
to-array is not sufficient, use clj-js On Fri, May 10, 2013 at 8:58 PM, Timothy Washington twash...@gmail.comwrote: Hi all, I'm trying to suss out some problems I'm encountering when compiling Clojurescript, down to Javascript. I'm using i) a 3rd-party charting library (highcharts.com),

Re: Untangling Compilation External Libs: Clojurescript - Javascript

2013-05-10 Thread Timothy Washington
Aha, that did the trick... for the array and the object. Cheers Tim -- -- 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

Re: A JMonkeyEngine3 wrapper?

2013-05-10 Thread AtKaaZ
Robert, do you have all that in a project somewhere on github? I really enjoy all the explanations On Fri, May 3, 2013 at 7:19 PM, Robert Louis McIntyre r...@mit.edu wrote: I've written some JME3 wrapper code for my thesis project -- it's not ready for prime time, but it's got some nice