2013-04-17
| 00:00 | capcrunch | anyone has used scriptjure ? i want to use jquery using this |
| 00:21 | muhoo | capcrunch: clojurescript seems to be the usual client side thing. jayq is a wrapper around jquery |
| 00:21 | capcrunch | yep , but i don't want to use clojurescript |
| 00:22 | capcrunch | muhoo jayq i'll take a look |
| 00:24 | muhoo | capcrunch: oh, well jayq may require cljs. check itd project.clj |
| 02:07 | kritztopf | Hey guys, I read a tutorial on Clojure and now I have one question: is it possible to write my own classes in Clojure? |
| 02:08 | SegFaultAX | kritztopf: Of course! |
| 02:08 | kritztopf | I can't find a thing on this topic |
| 02:08 | kritztopf | or I'm too stupid to find it |
| 02:08 | SegFaultAX | kritztopf: What are you trying to do? |
| 02:10 | kritztopf | let's say I have classes for geometrical objects, like Square and Circle. Do I just (def Circle....) or how do I do this in Clojure? |
| 02:10 | kritztopf | *I want to have classes |
| 02:11 | SegFaultAX | kritztopf: Sure, you can do that. But /why/ do you want classes? |
| 02:12 | kritztopf | because that's my naive approach to Clojure ^^. but with a functional paradigm classes may not be that necessary as in Java |
| 02:13 | SegFaultAX | kritztopf: There are lots of great resources available to get started with Clojure. |
| 02:13 | SegFaultAX | I personally suggest this: http://www.clojurebook.com/ |
| 02:13 | kritztopf | I'm reading through http://java.ociweb.com/mark/clojure/article.html atm |
| 02:13 | kritztopf | okay, will have a look at that |
| 02:14 | noidi | kritztopf, you should only use classes for interop with Java |
| 02:14 | SegFaultAX | kritztopf: I don't know if I agree with that approach. You should learn Clojure the "Clojure Way". Not Java by example in Clojure. |
| 02:14 | SegFaultAX | noidi: That's not the only reason to introduce a class, but it's definitely a good one. |
| 02:14 | kritztopf | okay |
| 02:43 | james1 | Does anyone know of a good tutorial about setting up emacs as an ide for clojure? I have GNU Emacs 24.2.1 (x86_64-suse-linux-gnu, GTK+ Version 3.4.4) |
| 02:43 | james1 | of 2012-10-10 on build20. And nothing seems to work! Tried nrepl but when i try to "jack-in" I get the error message inferior-lisp-proc: No Lisp subprocess; see variable `inferior-lisp-buffer' and I see no repl. Any help would be great! thanks. |
| 02:46 | ebaxt | james1: I used https://github.com/technomancy/emacs-starter-kit to get started quickly. If you just want to get something up and running it's a good start, eventually you probably want to modify stuff. Another "out of the box" solution is http://overtone.github.io/emacs-live/. |
| 02:49 | james1 | thanks ebaxt. Does the emacs started kit include clojure? |
| 02:52 | ebaxt | yes. Btw, I think the problem you are experiencing might have something with an invalid project root, since the nrepl-jack-in tries to launch an nrepl server |
| 02:56 | james1 | the funny thing is that it says I am "connected"... |
| 03:01 | james1 | the other thing is I am currently under opensuse. I do the same command in ubuntu and it works! Something must be missing.... |
| 03:05 | james1 | the emacs-live worked! |
| 03:05 | james1 | thanks! |
| 03:05 | ebaxt | np |
| 03:56 | asaleh | question: is there a way to add type anotations to a record? |
| 03:58 | amalloy | asaleh: for what purpose? |
| 03:59 | asaleh | amalloy, want to get better errors in my system |
| 04:05 | asaleh | amalloy, Ibut I think I have found somethin that lookslike what I need https://gist.github.com/richhickey/377213 |
| 04:10 | clgv | asaleh: you want to type record fields? |
| 04:10 | asaleh | clgv, yes, that is what I want :) |
| 04:10 | clgv | asaleh: you cant do that the way you (probably) imagine |
| 04:12 | clgv | you can type hint (1) primitive types int, long, double and such, and (2) general classes - for the two cases there are different effects |
| 04:12 | clgv | for (1) the field of the generated class will have the primitive type you hinted |
| 04:13 | asaleh | clgv, and 2? |
| 04:13 | ucb | are there any libraries for load testing you guys would recommend? |
| 04:13 | clgv | for (2) reflection will be avoided when calling java methods on the values of those fields - that means a cast is inserted at the java method call |
| 04:13 | ucb | I'm wanting to test a multi-threaded graphite client which is claiming to be overloaded. |
| 04:13 | clgv | (2): but only in the inline method implementations of that defrecord |
| 04:16 | clgv | asaleh: there is typed clojure (core.typed) from ambrose though - which may contain type checks for records (I am not sure since I did not check out its feature set yet) |
| 04:25 | asaleh | clgv, so there is not a easy way how to force my code to fail as soon as I create record with some field with wrong type? Because I don't want to create my own macro for checking ... |
| 04:45 | clgv | asaleh: you can implement a cunstructor function that type checks all arguments |
| 04:45 | clgv | *constructor |
| 04:46 | asaleh | clgv, yes, that is what I am trying to do now :) |
| 04:48 | clgv | asaleh: you need a constructor function anyway, when you want to create records from a different namespace. (clojure 1.4+ generates the function ->MyRecord for you which you should not use when you want to implement your type checks.) |
| 05:03 | dbushenko | hi all! |
| 05:03 | dbushenko | how to start a clojurescript repl in emacs? |
| 05:13 | xeqi | dbushenko: https://github.com/cemerick/piggieback |
| 05:13 | dbushenko | xeqi, thanks! |
| 05:28 | naeg | is there something like drop-while which returns everything from start up to the first logical false instead of from first logical false to end? or do I have to (reverse coll)? |
| 05:34 | jack_rabbit | I've set up a proxy interface that's suddenly not working. Here's the code: http://pastebin.com/4uaqAs0k |
| 05:35 | jack_rabbit | I'd appreciate any help. It's a good chunk of code, but I think most of it isn't relevant. |
| 05:35 | ucb | naeg: you can try take-while |
| 05:36 | naeg | ucb: thanks, didn't think of that one |
| 05:48 | jack_rabbit | In general, why might a proxy fail? The java code appears to be finding the proxy, and running the proper method, but the code in the proxy isn't executing. |
| 05:51 | ivan | jack_rabbit: I think the method in your proxy is returning a function |
| 05:52 | ivan | try without the # |
| 05:52 | jack_rabbit | OOF! Duh. |
| 05:53 | jack_rabbit | That hurts. |
| 05:53 | jack_rabbit | Thanks, guys. |
| 05:54 | jack_rabbit | Sure enough... |
| 05:54 | naeg | can I somehow create a lazy seq of function calls like this: (f (f (f 1 2) 3) 4) |
| 05:55 | naeg | so I can do a take-while on them |
| 05:55 | ucb | ,(doc repeatedly) |
| 05:55 | clojurebot | "([f] [n f]); Takes a function of no args, presumably with side effects, and returns an infinite (or length n if supplied) lazy sequence of calls to it" |
| 05:55 | ucb | hum, not that one |
| 05:58 | naeg | I actually want to produce this in clojure: http://pastebin.com/UwydC1WG |
| 05:58 | ucb | oh, blah, that's reduce |
| 05:58 | ucb | ,(doc reductions) |
| 05:58 | clojurebot | "([f coll] [f init coll]); Returns a lazy seq of the intermediate values of the reduction (as per reduce) of coll by f, starting with init." |
| 05:58 | naeg | my thought was to(last (take-while cond2 (f (f (f 1 2) 3) 4))) |
| 05:59 | ucb | naeg: (reductions f [1 2 3 4 5]) would produce something like ((f 1 2) (f (f 1 2) 3) (f (f (1 2) 3) 4) ...) |
| 05:59 | ucb | ,(reductions + [1 2 3 4]) |
| 05:59 | clojurebot | (1 3 6 10) |
| 06:08 | clgv | +1 for reductions |
| 06:11 | naeg | does the clojure code below do the same as the pseudocode above? http://pastebin.com/JPvvS4zm |
| 06:12 | naeg | it does not work as it should right now, but could be a fault somewhere else too |
| 06:12 | hyPiRion | naeg: yes, I think so, but it's better to utilize reduced instead I think |
| 06:13 | naeg | beside, cond2 is inverted in the clojure code |
| 06:14 | hyPiRion | ,(reduce (fn [acc n] (let [v (+ acc n)] (if (= n 8) (reduced v) v))) 0 (range)) |
| 06:14 | clojurebot | 36 |
| 06:16 | naeg | doesn't really seem simpler to me? |
| 06:17 | naeg | also, last paste was wrong: http://pastebin.com/zvCZLT9U |
| 06:19 | hyPiRion | naeg: true, not if your condition only depends on the result, and not the input |
| 06:19 | hyPiRion | or a combination, for that matter |
| 06:22 | naeg | hyPiRion: put cond in some context: http://pastebin.com/u1QR3bzX |
| 06:23 | hyPiRion | yeah, then reductions is fine |
| 06:25 | naeg | thanks |
| 06:25 | hyPiRion | ,(->> (range) (reductions max 0) (drop-while (partial <= 5)) first) |
| 06:25 | clojurebot | 0 |
| 06:26 | hyPiRion | ,(->> (range) (reductions max 0) (take-while (partial <= 5)) first) ;* |
| 06:26 | clojurebot | nil |
| 06:26 | hyPiRion | oh what. Well, you get the idea |
| 06:31 | naeg | I'll first try to make it work without ->>, it's confusing enough to me already ;) |
| 06:33 | hyPiRion | oh, alrighty |
| 06:59 | clgv | naeg: you can use `reduce` with a lambda function and `reduced` |
| 07:00 | thalassios_xelon | hello everyone :), https://www.refheap.com/paste/13704 simple question about concurency |
| 07:02 | clgv | thalassios_xelon: an agent excutes all its task sequentially. |
| 07:03 | clgv | thalassios_xelon: in principle it is a worker thread with state and an associated job-queue where it retrieves jobs executes them, updates its states with the job result and then retrieves the next job |
| 07:04 | thalassios_xelon | clgv, i got confused them about agents ok thanks i will read more |
| 07:05 | clgv | thalassios_xelon: you can do parallel computations via futures or clojure.core.reducers |
| 07:06 | thalassios_xelon | fold is only for very big collections? |
| 07:07 | thalassios_xelon | reduces any tutorial? |
| 07:07 | clgv | you can say it like that. the general principle is that you need enough work for a thread so that the overhead is not bigger than the computation time needed. |
| 07:07 | thalassios_xelon | http://clojure.com/blog/2012/05/08/reducers-a-library-and-model-for-collection-processing.html i found only this |
| 07:09 | clgv | thalassios_xelon: the basic idea is to use the functions (map, reduce, filter ...) of clojure.core.reducers as drop-in replacements for the ones in clojure.core |
| 07:10 | thalassios_xelon | ok thanks clgv :) |
| 07:16 | katratxo | hi all, how can i hint the compiler on this call to FileUtils ? https://www.refheap.com/paste/13706 |
| 07:20 | clgv | katratxo: do you need to? what are the java signatures for that method? to me it looks as if all types are inferable |
| 07:21 | katratxo | clgv: the return type is Collection<File> .. the signature is File, String[], boolean |
| 07:22 | clgv | katratxo: oh, ok the `into-array` has not :tag and is not inlne |
| 07:24 | katratxo | clgv: the :tag? |
| 07:24 | clgv | katratxo: you have to hint the string array. ^"[Ljava.lang.String;" |
| 07:25 | katratxo | ha! thanks, will try it |
| 07:27 | katratxo | clgv: thank you! that was it :) |
| 07:43 | Deleteyrself | shut up and listen some http://anonpt.caster.fm/ |
| 07:45 | bosie | how would i create a thread-safe function that is cached |
| 07:46 | bosie | memoizing |
| 08:24 | capcrunch | anyone uses scriptjure ? |
| 08:56 | clgv | bosie: check whether memoize is built correctly with atoms then it is thread-safe. I thought it was |
| 08:56 | bosie | clgv: hm, ok |
| 08:57 | clgv | bosie: did you encounter any error that makes you believe otherwise? |
| 08:57 | bosie | clgv: no, but i am not sure how to test it either |
| 08:58 | clgv | yeah should be threadsafe. although it might calculate value more than once in worst case scenarios |
| 08:59 | clgv | bosie: for more advanced memoization there is core.memoize |
| 09:00 | bosie | clgv: even core.memoize doesn't mention thread-safety |
| 09:00 | bosie | clgv: but i will look into it |
| 09:01 | clgv | bosie: maybe the authors think it's self-evident that it must be thread.-safe to be of any use... |
| 09:02 | bosie | clgv: yes, and tests are used as documentation ;) |
| 09:02 | clgv | bosie: the readme could improve its documentation amount right. |
| 09:03 | clgv | bosie: though there is not much document for just using core.memoize since you just do (memo-lu f) or similar ^^ |
| 09:04 | clgv | bosie: the kinds of caches could be explained for people that dont know the names |
| 09:04 | bosie | indeed |
| 09:04 | bosie | but the documentation could be improved almost everywhere. at times it reads like a math book ;) |
| 09:05 | bosie | not so brainy ppl like me take a bit longer to grasp it |
| 09:05 | gdev | salutations fellow clojurists |
| 09:06 | clgv | hmm the docstrings of core.memoized are quite verbose though |
| 09:06 | bosie | clgv: "Positional factory function for class clojure.core.memoize.PluggableMemoization." |
| 09:07 | bosie | ok to be fair that was bad luck i found this as the first docstring it seems |
| 09:13 | naeg | someone having experience with minimax and alpha-beta pruning? |
| 09:14 | naeg | wrote both in clojure and alpha-beta (more exactly negamax) is only 1 second faster than minimax on a 6x7 connect four board calculating 4 steps |
| 09:14 | naeg | is that unusual? |
| 09:14 | naeg | minimax takes 2.5sec and alpha-beta 1.6 sec |
| 09:17 | hyPiRion | naeg: what is the branch factor? |
| 09:18 | hyPiRion | ,(Math/pow 7 4) |
| 09:18 | naeg | I guess it's 7? if you mean how many possible moves one has his turn |
| 09:19 | hyPiRion | ,(* 7 7 7 7) |
| 09:19 | hyPiRion | &(* 7 7 7 7) |
| 09:19 | lazybot | ⇒ 2401 |
| 09:19 | hyPiRion | well, that should be done in an instant |
| 09:19 | hyPiRion | not sure you're running 8 plies? |
| 09:20 | hyPiRion | That is, four moves for you and 3-4 moves for the opponent |
| 09:20 | naeg | nope, 4 moves in total. 2 times me 2 times opponent |
| 09:20 | clojurebot | 2401 |
| 09:20 | clojurebot | 2401.0 |
| 09:20 | hyPiRion | Well, that seems absurdly slow |
| 09:21 | naeg | clojurebot: you're slow |
| 09:21 | clojurebot | excusez-moi |
| 09:21 | naeg | the minimax too? |
| 09:21 | naeg | 2.5 sec |
| 09:21 | clgv | &(println "I am the faster one...") |
| 09:21 | lazybot | ⇒ I am the faster one... nil |
| 09:21 | hyPiRion | yeah |
| 09:22 | hyPiRion | let me think here |
| 09:23 | naeg | heuristic function takes about 0.2-0.15msec |
| 09:23 | hyPiRion | ,(* 16 15 14) |
| 09:23 | clojurebot | 3360 |
| 09:24 | hyPiRion | ,(* 16 15 14 13) |
| 09:24 | clojurebot | 43680 |
| 09:24 | hyPiRion | I manage to calculate that many different moves in 1 second sequentially in Quarto with alpha beta |
| 09:25 | hyPiRion | https://github.com/hyPiRion/snigilbot/blob/master/src/snigil/players/minimax.clj#L71-93 |
| 09:26 | hyPiRion | naeg: it may be that you're not creating the children lazily. That hit my performance at first attempty |
| 09:29 | naeg | hyPiRion: I'll take a closer look at your code, thanks. here is mine: http://pastebin.com/PszQWsnY |
| 09:29 | naeg | seems all lazy to me...I guess |
| 09:29 | ucb | this test has me a bit puzzled: https://gist.github.com/ulises/5404292 |
| 09:30 | naeg | oh, the docstrings are wrong partly |
| 09:31 | hyPiRion | naeg: negamax is the alpha-beta one? |
| 09:31 | naeg | hyPiRion: yes |
| 09:31 | naeg | inspired by this one: http://chessprogramming.wikispaces.com/Alpha-Beta#Implementation-Negamax%20Framework |
| 09:32 | hyPiRion | ah, okay. Hm. |
| 09:33 | naeg | using that (last (take-while cond (reductions ....) we talked about before |
| 09:33 | hyPiRion | yeah |
| 09:34 | hyPiRion | ,(range 100 1000 100) |
| 09:34 | clojurebot | (100 200 300 400 500 ...) |
| 09:36 | hyPiRion | ,(->> (range 100 1000 100) (map #(do (Thread/sleep 100) %)) (reductions max) last time) |
| 09:36 | hyPiRion | (Then wait half an hour) |
| 09:38 | naeg | hyPiRion: I can't follow you here? |
| 09:39 | clojurebot | "Elapsed time: 901.240846 msecs"\n900 |
| 09:42 | hyPiRion | naeg: the only thing I attempted was to figure out whether reductions would perform a calculation multiple times |
| 09:42 | hyPiRion | it doesn't |
| 09:42 | naeg | what about the (last) actually? does tha realize the seq? |
| 09:43 | hyPiRion | naeg: no, it would only pick the last element in the seq you get from take |
| 09:43 | hyPiRion | ,(->> (range 100 1000 100) (map #(do (Thread/sleep 100) %)) (reductions max) (take-while #(< % 400)) last time) |
| 09:43 | clojurebot | "Elapsed time: 905.020026 msecs"\n300 |
| 09:44 | naeg | but the values returned by negamax are realized already, right? since take-while checks them with the pred |
| 09:44 | hyPiRion | gurr |
| 09:44 | naeg | at last up to first logical false |
| 09:44 | hyPiRion | ,(->> (range 100 1000 100) (map #(do (Thread/sleep 100) %)) (reductions max) (take-while #(< % 400)) time) |
| 09:44 | clojurebot | "Elapsed time: 0.868794 msecs"\n(100 200 300) |
| 09:44 | hyPiRion | ,(->> (range 100 1000 100) (map #(do (Thread/sleep 100) %)) (reductions max) (take-while #(< % 400)) last time) |
| 09:44 | clojurebot | "Elapsed time: 901.426042 msecs"\n300 |
| 09:45 | hyPiRion | naeg: oh dangit, I know the root cause |
| 09:45 | hyPiRion | map is chunked lazy, so it evaluates 32 elements at a time |
| 09:46 | naeg | what could I use instead of map then? |
| 09:46 | hyPiRion | ,(first (map #(do (pr '.) %) (range))) |
| 09:46 | clojurebot | ................................0 |
| 09:47 | hyPiRion | naeg: fogus had a solution for this, let me look it up |
| 09:47 | hyPiRion | naeg: http://blog.fogus.me/2010/01/22/de-chunkifying-sequences-in-clojure/ |
| 09:47 | hyPiRion | It's not pretty, but it works |
| 09:48 | naeg | just wanted to say, seems cumbersome |
| 09:48 | hyPiRion | yeah. |
| 09:48 | naeg | you're using loop for that in sniglibot? |
| 09:52 | hyPiRion | no, I didn't know about that issue at that time |
| 09:53 | hyPiRion | ,(first (for [a (range)] (do (pr '.) a))) |
| 09:53 | clojurebot | ................................0 |
| 09:56 | naeg | hyPiRion: using seq1 doesn't change anything :/ |
| 10:00 | hyPiRion | naeg: bleh, then I'm not sure |
| 10:02 | naeg | hyPiRion: I'll try to find out by using sniglibot as a reference, thanks |
| 10:02 | hyPiRion | np |
| 10:03 | ambrosebs | asaleh: If you want runtime checking of record constructors see defconstrainedrecord in core.contracts. If you want static type checking, there's some support for records in the latest core.typed release. |
| 10:04 | clgv | ambrosebs: it seemed as if type check on construction was all he needed. |
| 10:05 | ambrosebs | core.contracts also gives type checking on map ops like assoc, update-in, if that's useful. |
| 10:07 | ambrosebs | FWIW core.typed has assoc checking too. |
| 10:08 | asaleh | ambrosebs, thanks, will look into it :) ... I have already updated my constructor to do basic typechecks, but if there is something better, than my 4 line macro, I will use it :) |
| 10:09 | ambrosebs | asaleh: You basically leave all your code as you would, but have (defconstrainedrecord MyRecord [a b] "Doc" [(my-contract1 a) (precondition2) b)]) instead of the defrecord |
| 10:09 | ambrosebs | It rocks. |
| 10:10 | ambrosebs | (with core.contracts) |
| 10:12 | ambrosebs | IIRC it even checks the bare java constructor. |
| 10:16 | asaleh | jweiss, this looks good https://github.com/fogus/trammel |
| 10:18 | asaleh | ambrosebs, I liked Trammels readme better :) ... has nice defconstrainedrecord example |
| 10:19 | ppppaul | how would i invalidate a memoized function? |
| 10:19 | ambrosebs | asaleh: fair enough :) |
| 10:20 | jweiss | can anyone tell me the general state of core.typed? seems like the examples i have read have a lot of forms that are not checked because of lack of support for various things |
| 10:20 | jweiss | is there a list of yet-to-be-implemented functionality i can watch |
| 10:21 | ambrosebs | jweiss: There's been some good progress lately. |
| 10:21 | ambrosebs | jweiss: Follow on the mailing list or Jira http://dev.clojure.org/jira/browse/CTYP |
| 10:22 | ambrosebs | jweiss: https://groups.google.com/forum/?fromgroups#!forum/clojure-core-typed |
| 10:23 | ambrosebs | jweiss: Latest features: multiple error messages per run, support for records, lazy loading of internals, wrapper macros for `for` and `doseq`. |
| 10:24 | jweiss | ambrosebs: i'll try it out, seems like it can't hurt :) |
| 10:25 | rektide | jasonjckn: thanks for the storm & kafka jars on clojars!! |
| 10:25 | ambrosebs | jweiss: Also optional and mandatory keyword args are supported :) |
| 10:25 | rektide | you don't happen to be a Developer in denver? i knew a jason jackson out there |
| 10:26 | ambrosebs | jweiss: Use this version, I can't make releases yet because the contrib infrastructure is broken. https://groups.google.com/forum/?fromgroups=#!topic/clojure-core-typed/LJLSl3GyMEY |
| 10:26 | ambrosebs | jweiss: Use this in your project.clj: :repositories {"sonatype-oss-public" "https://oss.sonatype.org/content/groups/public/"} |
| 10:28 | ambrosebs | jweiss: aaaand start here if you didn't find it before :) http://clojure-doc.org/articles/ecosystem/core_typed/home.html |
| 10:28 | jweiss | ambrosebs: yep i had seen that last one :) |
| 10:33 | learner_ | Hello guys, anyone using pallet with linode? |
| 10:42 | learner_ | Hello guys, anyone using pallet with linode? |
| 10:48 | clgv | learner_: maybe you have better success chances in the #pallet channel |
| 10:49 | nDuff | learner_: given as someone went through the trouble to write the jclouds support for linode, I'd certainly expect so. |
| 10:50 | learner_ | clgv: thanks, I couldn't get any response in pallet channel. Since our clojure channel has more members, thought one of you Gurus will answer. |
| 10:51 | learner_ | nDuff: Looked around but found nothing. Hope there is a solution available. Thanks for your response. |
| 10:51 | clgv | learner_: Hugo Duncan was often in the #pallet channel when I needed help around this time of the day... |
| 10:52 | nDuff | learner_: How long did you wait? Smaller IRC channels often have multi-hour lag before you get a response. |
| 10:52 | learner_ | clgv: I see him there. Will ping him. Thanks |
| 10:53 | learner_ | nDuff: May be you are right. my session is on for about 5 hours. Will keep it on. Thanks |
| 10:54 | nDuff | learner_: ...it also helps to ask a detailed question, rather than "does anyone [...]" |
| 10:55 | learner_ | nDuff: Excuse me for my short question. I will soon post a detail question. Thanks for your time |
| 11:16 | cmajor7 | how do you guys deal with hiccup templates (partials) and compojure routes? e.g. "(GET "/some-route" [] (body(how-to-partial)))". Here "body" is a function with a header and footer with all the CSS/JS includes. And "how-to-partial" is a hiccup function that just returns a "how to" portion. what would a better way be? |
| 11:17 | asteve | what is a "\"how to\" portion"? |
| 11:22 | TimMc | alexbaranosky: y u no tag? :-( |
| 11:28 | danneu | cmajor7: then you'd have really repetitive routes. body(this).. body(that). |
| 11:29 | danneu | cmajor7: instead why not map routes to the fns that represent that page. then that page fn can do whatever it wants. nest a thousand partials, be composed of 30 other fns, whatever. |
| 11:29 | danneu | i may've misunderstood |
| 11:32 | ucb | when writing tests (whether midje or otherwise) how do you guys go about checking that a fn doesn't throw? do you wrap in a try/catch and fail the test in the catch clause? |
| 11:32 | ucb | (I suppose that exceptions make the test fail anyway and stop execution anyway) |
| 11:32 | cmajor7 | danneu: no you understood correctly. that is how I approached it at the first pass. however that means that there should be a unique function for each route that combines header/partial(s)/footer. while it is ok, it creates an unnecessary two liners e.g. (defn route-x [] (body(single-partial-x))) … (defn route-y [] (body(single-partial-y))) |
| 11:33 | noidi | ucb, isn't not throwing the default? :) |
| 11:33 | ucb | noidi: sure, but alternatively you could check the opposite. I'm wondering about exception handling during tests |
| 11:34 | noidi | I think all test frameworks report thrown, unexpected exceptions as errors |
| 11:34 | noidi | just check that the return value / side effects and you're done |
| 11:35 | cmajor7 | danneu: I am in a noir rebound, where the magical noir powers that are "no longer" solved that. I can't recall how exactly. so I am thinking what is the preferred/idiomatic way to do it with compojure |
| 11:36 | ucb | noidi: yeah, I think my problem stems from the fact that these exceptions are being thrown in other threads, and caught and reported elsewhere :/ |
| 11:36 | ucb | noidi: thanks anyway :) |
| 11:44 | TimMc | alexbaranosky: More seriously, I added tags to https://github.com/timmc/clj-schema -- you can pull them if you'd like. |
| 11:46 | TimMc | I did not verify that they match the Clojars artifacts, though. |
| 11:52 | aeberts | hi all :-) could someone help me with a newbie clojure question please? |
| 11:53 | ucb | aeberts: don't ask to ask? |
| 11:53 | aeberts | Can anyone tell me why this is throwing an error on line 7? http://pastebin.com/yE4WyqDh |
| 11:54 | aeberts | error: ClassCastException java.lang.Long cannot be cast to clojure.lang.IPersistentCollection |
| 11:54 | aeberts | clojure.core/conj (core.clj:83) |
| 11:54 | aeberts | alpen.core/fiber (core.clj:198) |
| 11:54 | aeberts | alpen.core/eval1596 (NO_SOURCE_FILE:1) |
| 11:56 | joegallo | aeberts: your loop expects a list for result |
| 11:57 | joegallo | your recur at line 8 is passing it a number |
| 11:57 | noidi | aeberts, on line 8 your recur is setting result to (dec n) |
| 11:57 | noidi | damn, joegallo beat me to it :) |
| 11:57 | joegallo | i'm fast |
| 11:57 | aeberts | thanks joegallo - does that mean that the args to loop act like function args? |
| 11:58 | joegallo | ehhhhhhhhh |
| 11:58 | joegallo | sortof |
| 11:58 | joegallo | yes |
| 11:58 | aeberts | i.e. args to recur have to be the same as the arg list in loop? |
| 11:58 | joegallo | yes |
| 11:58 | aeberts | ok, thanks for the help! |
| 11:59 | joegallo | (loop [x 3 y []] ... (recur 4 [4 5])) ;; in the iniial loop statement, it's a bit like a let. in the later recur, though, it's like a function call. |
| 11:59 | joegallo | so on the next run through the loop, x will be 4 and y will be [4 5] |
| 11:59 | TimMc | The loop bindings are *very* similar to fn bindings, yes. |
| 11:59 | noidi | aeberts, recur jumps back to the nearest recursion point, which is either a loop statement or a function declaration |
| 11:59 | aeberts | I see - I have to pass the "index" and the seq |
| 12:01 | noidi | in your case the nearest recursion point is the loop, so you have to give recur the next values for the names initialized in the loop statement |
| 12:01 | aeberts | noidi - thanks for the help. |
| 12:03 | rasmusto | tpope: ok, thanks for the response. Sometimes I like to pull up a version of a function from a few commits back and slam it into the repl to see what happens. |
| 12:23 | ppppaul | hey guys. i have a really weird problem. i brought down a lib (camel-snake-kebab) and got it working in my repl... i then brought in a new lib (timbre) and got it working, however now i'm getting an exception saying that camel_snake_kebab.clj isn't found |
| 12:23 | ppppaul | i looked in .m2 and it's there |
| 12:23 | ppppaul | lein classpath | tr : \n | grep snake works too |
| 12:24 | nDuff | ppppaul: Could you provide enough detail to reproduce? |
| 12:24 | nDuff | ppppaul: something we can ''git clone'' to see the problem ourselves would be ideal. |
| 12:24 | ppppaul | ok... i'll set up a public repo |
| 12:25 | l1x | aeberts: have you considered something like this? https://github.com/l1x/euler/blob/master/src/euler/core.clj#L55 |
| 12:28 | aeberts | l1x - yes, that was my first thought but I wanted to exercise my understanding of loop and recursion in clojure and I'm glad I did because I learned something in the process… the implementation you showed is a better approach. Thanks! |
| 12:29 | ppppaul | hmm... i just moved my files to somewhere else and now the lib is loading properly again... |
| 12:29 | ppppaul | gah |
| 12:29 | ppppaul | my head... |
| 12:29 | l1x | aeberts: i see. this implementation is form the joy of clojure if i remember correctly, i guess loop+recursion is important to understand anyways |
| 12:31 | aeberts | I prefer the implementation you referenced - it's more clojuresque. |
| 12:31 | ppppaul | nDuff killing emacs seems to have solved my problem |
| 12:31 | ppppaul | ug |
| 12:31 | ppppaul | time for candy |
| 12:58 | thalassios_xelon | if i have 4 agents(with work to do) in a 4 thread system,are they work in parallel? |
| 13:00 | nDuff | thalassios_xelon: in general, yes. In Clojure 1.5, you can get detailed control of the thread pool if you want it. |
| 13:00 | thalassios_xelon | ok thanks |
| 13:00 | nDuff | thalassios_xelon: It doesn't matter for only 4 agents, but are you invoking with send or send-off? |
| 13:00 | clojurebot | Excuse me? |
| 13:01 | thalassios_xelon | with send |
| 13:01 | nDuff | thalassios_xelon: ...then at most (number_of_processes + 2) threads will be running at once, unless you replace the pool yourself. |
| 13:08 | thalassios_xelon | i am doing something like https://www.refheap.com/paste/13716 |
| 13:08 | thalassios_xelon | to use agents in parallel |
| 13:10 | thalassios_xelon | sorry that -> https://www.refheap.com/paste/13718 |
| 13:14 | technomancy | yogthos: hey, we're checking up on the possible clojars intrusion; do you recall whether you deployed over an existing deployment of lib-noir and luminus/lein-template last week? |
| 13:14 | nDuff | thalassios_xelon: Eww. |
| 13:15 | thalassios_xelon | eww means? |
| 13:16 | nDuff | thalassios_xelon: Not very functional code. Lots and lots of recur. |
| 13:18 | thalassios_xelon | ok but the way i try to get it parallel its ok? |
| 13:19 | naeg | hyPiRion: tried it with reduce/reduced now and still same execution time. any idea what's a good place to ask what's going on there? stackoverflow? |
| 13:26 | yogthos | technomancy: hey I'd have to check |
| 13:28 | yogthos | technomancy: I think I did a deploy of lib-noir 6 days ago |
| 13:28 | technomancy | yogthos: sure; I mean a re-deploy over an existing version specifically |
| 13:29 | yogthos | technomancy: it's likely but I'm not 100% sure |
| 13:29 | yogthos | technomancy: I think I released version 0.5 and didn't promote it right away |
| 13:29 | technomancy | no problem; I plan on reviewing diffs manually anyway |
| 13:30 | yogthos | technomancy: ok cool, but I would say it's most likely that it was me |
| 13:44 | TimMc | reiddraper: We should totally have a keysigning event at the next Boston Clojure Meetup, along with a demonstration of jarsigning. |
| 13:45 | TimMc | reiddraper: I don't know if I can volunteer to arrange the whole thing, but I've deployed some signed jars on clojars. |
| 13:55 | jweiss | anyone know how in core.typed, i would annotate the map constructor that is generated automatically? |
| 13:56 | jweiss | seems like it would be redundant to annotate the record itself and the constructor, it's the same info |
| 13:57 | technomancy | for anyone following along re: the possible clojars break-in, we've confirmed all but 45 jars |
| 13:57 | reiddraper | TimMc: that'd be awesome |
| 13:58 | technomancy | if your dependency tree doesn't include anything from http://p.hagelb.org/clojars-redeployed.html you should be safe |
| 13:58 | technomancy | well, as safe as you were before the break-in; you're still probably depending on unsigned jars |
| 13:59 | technomancy | if you do use any of those libs and you have a copy older than april, let me know |
| 14:04 | thalassios_xelon | https://www.refheap.com/paste/13718 is this a normal way to achieve parallezation? |
| 14:09 | tyler_ | woohoo my copy of process and reality came today |
| 14:10 | amalloy | thalassios_xelon: no, that is bonkers |
| 14:10 | technomancy | amalloy: hey, do you recall whether you may have redeployed flatland/phonograph in the past few weeks? |
| 14:10 | amalloy | use futures, or pmap, or anything but this |
| 14:10 | amalloy | technomancy: i'm sure i have |
| 14:11 | technomancy | amalloy: specifically redeploying over an existing version |
| 14:11 | stuartsierra1 | technomancy: Thanks for preparing the list. |
| 14:11 | amalloy | right, i understood |
| 14:11 | technomancy | amalloy: ok cool; thanks |
| 14:11 | amalloy | technomancy: i can redeploy again, if you can tell me which versions are questionable |
| 14:11 | technomancy | amalloy: just interested in confirming that it happened at this point; thanks |
| 14:12 | amalloy | k |
| 14:12 | technomancy | though if you have it still in your m2 and could paste a sha1sum that might help actually |
| 14:12 | amalloy | technomancy: sure. what version? |
| 14:12 | technomancy | of 0.1.4 |
| 14:13 | amalloy | $ cat phonograph-0.1.4.jar.sha1 ## 1d8838b7bf8762b92a0d2881c260aa5c1f9eae63 |
| 14:13 | technomancy | yogthos: if you could do the same for lib-noir 0.5.0 and luminus 0.5.3 and 0.5.5 that'd be tops |
| 14:13 | technomancy | amalloy: thanks |
| 14:13 | technomancy | stuartsierra1: yeah, just glad things appear to be clean. it's a good wake-up call. |
| 14:14 | technomancy | in case the rubygems break-in wasn't enough of one =) |
| 14:14 | yogthos | technomancy: yeah I can deploy the latest when I get home tonight |
| 14:14 | technomancy | yogthos: just the checksum would be fine |
| 14:14 | technomancy | (if you have it from the machine on which it was deployed from) |
| 14:14 | technomancy | if not no big deal; I will probably be able to get it from another source once he comes online =) |
| 14:18 | tyler_ | im thinking about using var- to prefix my symbols that are bound to vars |
| 14:18 | tyler_ | you think thats stupid? |
| 14:18 | tyler_ | my reasoning is so i don't accidently rebind symbols bound to functions |
| 14:19 | amalloy | tyler_: yes, that is silly |
| 14:19 | technomancy | tyler_: every symbol that's not a local is bound to a var |
| 14:19 | tyler_ | ah <---- newb |
| 14:19 | technomancy | (not technically true, but enough to make it a bad idea) |
| 14:19 | amalloy | technomancy: that's not really true at all, right? |
| 14:20 | technomancy | heh |
| 14:20 | TimMc | tyler_: If you're worried about shadowing vars with locals, there might be a lein plugin that can warn you about those. |
| 14:36 | tomoj | huh, ##([1] 0 0) |
| 14:36 | lazybot | clojure.lang.ArityException: Wrong number of args (2) passed to: PersistentVector |
| 14:46 | yogthos | technomancy: ok sure thing |
| 14:47 | TimMc | tomoj: Yeah, vectors don't have an optional not-found arg. |
| 14:47 | TimMc | It would have made some Swearjure programs easier. |
| 14:56 | stuartsierra1 | ,(get [:a :b :c] 4 :not-found) |
| 14:56 | clojurebot | :not-found |
| 14:58 | SegFaultAX | Not sure why, but using vectors in function position looks really ugly to me. |
| 14:58 | SegFaultAX | I'm fine with sets and maps, but vectors? Just use get. |
| 14:58 | Chousuke | generally you wouldn't usea literal vector |
| 14:59 | SegFaultAX | ,([:a :b] 10) |
| 14:59 | clojurebot | #<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException> |
| 14:59 | SegFaultAX | ,({} :a) |
| 14:59 | clojurebot | nil |
| 15:00 | SegFaultAX | That discrepancy annoys me. |
| 15:00 | TimMc | ,(apply trampoline #{2 ["a" "b" "c"]}) |
| 15:00 | clojurebot | "c" |
| 15:00 | amalloy | SegFaultAX: that calling two different functions behaves differently? use 'get if you want something that acts like 'get |
| 15:00 | TimMc | Allow me to recalibrate your sense of "ugly". |
| 15:01 | SegFaultAX | amalloy: Didn't I just say that? |
| 15:01 | hiredman | ,(get [:a :b] 10) |
| 15:01 | clojurebot | nil |
| 15:01 | amalloy | no, you said that the discrepancy annoys you |
| 15:01 | hiredman | ,(get [:a :b] 0) |
| 15:01 | clojurebot | :a |
| 15:01 | SegFaultAX | Read ^ |
| 15:02 | SegFaultAX | 11:58 < SegFaultAX> I'm fine with sets and maps, but vectors? Just use get. |
| 15:26 | ssideris_ | hello |
| 15:27 | ssideris_ | is anyone getting "error in process sentinel: nrepl-sentinel: Wrong type argument: stringp, nil" with nrepl.el in windows? |
| 15:27 | ssideris_ | right after connecting |
| 15:28 | ssideris_ | nrepl 0.1.7, clojure 1.5.1, leiningen 2.1.3 |
| 16:37 | arrdem | technomancy: is there an nrepl port of slamhound? |
| 16:38 | arrdem | -__- yours supports nrepl. I'll rtfm next time. |
| 17:08 | rlb` | lb |
| 17:16 | TimMc | ls |
| 17:16 | lazybot | bin data dev home lib media mnt root selinux src srv sys tmp var |
| 17:40 | callen | Raynes: don't say I didn't warn you. |
| 17:41 | Raynes | callen: Can you sing like Kris Allen? |
| 17:41 | callen | Raynes: ...no. I warned you CLJS wasn't the province of those that give a damn. |
| 17:41 | callen | Raynes: incidentally, Prismatic used to do backend CLJS, but they switched. |
| 17:41 | callen | Because they're smart. |
| 17:41 | callen | and because node is awful. |
| 17:42 | Raynes | callen: http://dl.dropbox.com/u/23745600/Screenshots/BjcV.png What I take from this: people agree with me, but like Stuart Sierra too much to want to be upset with him. :P |
| 17:43 | Raynes | I'm not really a fan of node, but it is likely the best option we'll have for a while for a Clojure-like language with reasonably speedy startup speeds. |
| 17:43 | Raynes | Nobody gives any shits about the other Clojure implementations, which is unfortunate. |
| 17:43 | callen | Raynes: sigh...I know... :( |
| 17:43 | Raynes | There was plenty of interesting ones. |
| 17:43 | Raynes | clojure-py is my favorite, but even it has slow startup speed. |
| 17:43 | callen | Raynes: I could really use the better startup speed, but I've been having an okay time with Clojure Control in spite of it. |
| 17:44 | technomancy | Raynes: you've got a tweet favourited by HipsterHacker; congratulations, you win at twitter, etc |
| 17:44 | SegFaultAX | Raynes: Do you include normal Clojure in "other implementations"? |
| 17:44 | callen | SegFaultAX: normal Clojure is a diesel truck engine. |
| 17:44 | SegFaultAX | callen: Does that mean no one gives any shits about it? |
| 17:44 | Raynes | SegFaultAX: No. I'm specifically referring to ones with fast startup. |
| 17:44 | callen | SegFaultAX: lern2read |
| 17:45 | Raynes | callen: There is the off chance that he doesn't understand diesel engines and thus doesn't have the foggiest idea what you mean. |
| 17:45 | callen | Raynes: I always forget yuppies exist. |
| 17:46 | Bronsa | >lern2read |
| 17:46 | Bronsa | I see what you did there. |
| 17:47 | Raynes | technomancy: Hipster Hacker is a big deal? |
| 17:47 | Raynes | "Erlang is better than yer lang." |
| 17:47 | Raynes | Yep, he's a big deal. |
| 17:49 | SegFaultAX | callen: Oh I missed the part where he was talking about Clojure-like languages. |
| 17:51 | kmicu | > (([1])) |
| 17:57 | arrdem | okay so slamhound is cool, but are there any good tools for moving vars around between namespaces? |
| 18:14 | technomancy | arrdem: there's a clojure-refactoring tool that has been vehemently disowned by its author =) |
| 18:15 | trptcolin | tcrayford vehemently disowns a lot of stuff |
| 18:15 | arrdem | technomancy: haha is that joodie/clojure-refactoring? |
| 18:15 | technomancy | trptcolin: good point |
| 18:15 | arrdem | ah that's why joodie took it over |
| 18:15 | arrdem | what was the reason for writing it off? |
| 18:16 | trptcolin | please tell me it's written in "rubby" |
| 18:16 | trptcolin | rats |
| 18:16 | technomancy | arrdem: seemed mostly because it was written as an exercise to learn Clojure |
| 18:19 | arrdem | that's unfortunate... seems like something along those lines could be a valuable tool |
| 18:19 | arrdem | and the joodie mirror hasn't been ported to nrepl yet.. push that to the heap |
| 18:19 | danielglauser | doh! My slacking has been called out |
| 18:58 | lynaghk | Is nREPL any smarter than Slime/Swank in that ALL communication about source code goes through its pipe? |
| 18:58 | lynaghk | i.e., it should be possible for me to launch an nrepl server on a remote machine but use my local editior commands ("load this buffer") to source all code |
| 19:00 | amalloy | lynaghk: M-x nrepl-eval-buffer or similar probably exists |
| 19:00 | amalloy | just as it does for swank |
| 19:00 | arrdem | lynaghk: yes you can run a remote nrepl server and send arbitrary code to it |
| 19:00 | lynaghk | amalloy: yeah, I'm just wondering if it's any smarter than swank's implementation. I'm still using slime/swank, but if I do a command like "eval buffer" then the backend whines about not being able to find that file |
| 19:01 | amalloy | lynaghk: no, that's what happens if you do a command like "load file" |
| 19:01 | lynaghk | since, of course, it doesn't exist on the remote machine. |
| 19:01 | amalloy | if you actually do eval-buffer, it evals the buffer |
| 19:01 | lynaghk | amalloy: ah, noted. maybe I should just change my swank keybindings. |
| 19:02 | amalloy | (this probably has unwanted side effects, since load-file does some smart things like resetting your *ns* back to where it was after loading) |
| 19:02 | amalloy | but in general it's possible |
| 19:13 | technomancy | eval-region if the file doesn't exist remotely |
| 19:14 | tieTYT2 | i don't know anything about ring. Will it be hard for me to use compojure? |
| 19:14 | patchwork | insufficient information |
| 19:15 | patchwork | tieTYT2: only one way to find out: try it! |
| 19:16 | tieTYT2 | well, I already have a war and I'm creating a new war in a big ear that needs to reuse a lot of code. We're building a rest web service in this second war. I barely know what ring is, but I looked at compojure and it looks easier to use than java's jersey |
| 19:16 | tieTYT2 | so I'd like to use compojure |
| 19:16 | patchwork | ring's driving design principle is simplicity |
| 19:16 | tieTYT2 | i don't think that's javaee's driving principle. Can they work together? |
| 19:17 | patchwork | compojure is a tool for defining routes on top of basic request/response cycle |
| 19:17 | patchwork | Java is extremely easy to use from inside clojure |
| 19:17 | ivan | you go to war with the wars you have, not the wars you wish you had |
| 19:18 | tieTYT2 | yeah and it looks like an easy way to build a rest api with compojure. But I'm not sure if it's possible to take a war and use compojure inside of it |
| 19:18 | brehaut | theres a lein thing for doing ring wars |
| 19:19 | patchwork | You mean a war that already exists? |
| 19:19 | brehaut | ring is server agnostic; just use the appropriate adapter |
| 19:19 | tieTYT2 | patchwork: exactly |
| 19:19 | brehaut | oh the other way |
| 19:19 | patchwork | Yeah, that may be tricky |
| 19:19 | patchwork | still doable though, but you have to call clojure from inside java |
| 19:19 | tieTYT2 | or it could be a war from scratch, but it's gotta reuse a lot of code from an ear |
| 19:20 | brehaut | you'd need to synthesis a request object in a handler |
| 19:20 | brehaut | (or write an adapter that includes the original request in the ring map i guess) |
| 19:22 | tieTYT2 | hrm, sounds like a high learning curve |
| 19:22 | clojurebot | learning a new runtime is much harder than learning a new language. |
| 19:22 | tieTYT2 | if I were building the war from scratch, does that make things much easier? |
| 19:23 | patchwork | You can take a compojure project and generate a war from that |
| 19:23 | patchwork | no java needed |
| 19:23 | tieTYT2 | interesting, but my web.xml has <ejb-local-ref> entries that it depends on |
| 19:23 | tieTYT2 | will that be a problem? |
| 19:24 | brehaut | Madness → ring: easy; ring → madness: hard |
| 19:24 | tieTYT2 | i definitely need to do more research, I just don't know how to prioritize what I research :P |
| 19:43 | patchwork | So if my lib uses a ref for something, all libs that reference that lib can only have one value for that ref between them right? |
| 19:44 | patchwork | What if they each want to use the lib in a different way? |
| 19:44 | patchwork | What if (more likely) they don't even know other libs are using that lib and they don't realize they are crossing wires, so to speak |
| 19:44 | brehaut | patchwork: do you mean you have a namespace global var holding a ref? |
| 19:44 | patchwork | brehaut: Yeah |
| 19:45 | brehaut | patchwork: well dont do that ;) |
| 19:45 | patchwork | Is there a better way to do that? |
| 19:45 | brehaut | stuart sierra has a blogpost about that somewhere |
| 19:45 | patchwork | Ah, that would be helpful |
| 19:45 | brehaut | yeah, pass it as an argument |
| 19:45 | pppaul | is there some sort of clojure/lisp semantic merge tool? |
| 19:45 | brehaut | he's been doing a talk on it |
| 19:45 | pppaul | asking because of this http://www.infoq.com/news/2013/04/Semantic-Merge |
| 19:46 | brehaut | patchwork: http://stuartsierra.com/2013/03/29/perils-of-dynamic-scope is kind of on topic |
| 19:46 | patchwork | brehaut: So namespace global var holding a ref is a problem…. How do you get access to a ref that is not bound to a var somewhere? |
| 19:47 | brehaut | you pass it as an argument |
| 19:47 | patchwork | So you pass in the ref… but then it wouldn't need to be a ref |
| 19:47 | patchwork | Then it would just be functional |
| 19:47 | patchwork | I will read your link |
| 19:48 | brehaut | patchwork: well then, its an even bigger win |
| 19:49 | brehaut | patchwork: your other alternative is to close over ref and pass that function (or functions or reified type) around |
| 19:50 | patchwork | brehaut: Define the ref in a let, return a closure that modifies the ref? |
| 19:50 | brehaut | yes |
| 19:50 | patchwork | Okay, that sounds good |
| 20:10 | amalloy | i wonder if i can get stackoverflow to send me an email whenever an answer to a question tagged [clojure] contains the word "flatten" |
| 20:16 | the_walking_dead | hl |
| 20:18 | Raynes | Please don't eat me. |
| 20:19 | rasmusto | amalloy: haha, I scrubbed all instances of 'flatten' from my code the other day |
| 20:20 | Raynes | amalloy: It isn't *always* wrong. |
| 20:21 | Raynes | Just usually. |
| 20:21 | jgerman | flatten is usually wrong |
| 20:21 | jgerman | ? |
| 20:21 | Raynes | Yes. |
| 20:21 | amalloy | ~flatten |
| 20:21 | clojurebot | flatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with. |
| 20:21 | Raynes | It's usually a bandaid on a gushing wound. |
| 20:22 | jgerman | glad I decided to lurk |
| 20:22 | Raynes | You learn all sorts of things here. |
| 20:22 | Raynes | $know the meaning to life, the universe, everything |
| 20:22 | Raynes | That's very rude, lazybot. |
| 20:35 | weavejester | Does anyone happen to know why Clojure uses a thread pool of 2 + the number of processors for agents |
| 20:35 | weavejester | And not just a pool equal to the number of processors. |
| 20:36 | amalloy | weavejester: i think because at any given time some number of threads are likely to be blocking on IO or something |
| 20:36 | nightfly__ | So that it something finishes there will always be something in the ready list? |
| 20:36 | weavejester | amalloy: Ah, okay, so it's like a fudge factor |
| 20:36 | amalloy | weavejester: mostly my own speculation, though |
| 20:39 | weavejester | Hm… so the question is now, do I cargo-cult the clojure 2+available-processors, or do I just go with a pool of available-processors |
| 20:40 | weavejester | It probably doesn't matter, so I'll go with Clojure's scheme for now, and then test it later |
| 20:43 | chessguy | 'evening, ya'all |
| 20:47 | technomancy | weavejester: if possible please support the bring-your-own-thread-pool model |
| 20:47 | technomancy | it bugs me that clojure didn't support that for a long time |
| 20:47 | weavejester | technomancy: Yeah, me too |
| 20:48 | weavejester | technomancy: But in this case it's a specialized, CPU-bound case |
| 20:49 | weavejester | Actually, come to think of it… I could probably just use agents… |
| 20:49 | weavejester | I've gotten into the habit of using executors directly because they didn't have configurable thread pools |
| 20:51 | weavejester | That said, I don't need the output stored, either. |
| 20:53 | ambrosebs | jweiss: the map->* constructors should be typed automatically if the record is annotated with ann-record. |
| 20:54 | ambrosebs | jweiss: currently they might be a little restrictive, you must provide each record field as a key of the input map. |
| 21:22 | chessguy | so i'm assuming that lein has some local stash of jars from clojars? how do i find it |
| 21:22 | callen | chessguy: take a wild guess |
| 21:23 | amalloy | chessguy: `lein classpath` will tell you some interesting and useful things, unlike callen |
| 21:23 | chessguy | ah. i looked in ~/.lein, but it wasn't useful. thank you, amalloy |
| 21:24 | chessguy | hmm. those paths all seem to be in the project repository |
| 21:24 | amalloy | i rather doubt that |
| 21:25 | amalloy | at least the dependency on org.clojure/clojure should live elsewhere |
| 21:25 | chessguy | i can gist it for you, if you like... |
| 21:26 | chessguy | fairly certain i'm sane tonight, though... |
| 21:26 | weavejester | The lein jar cache is the same as the maven one; it's in ~/.m2 |
| 21:27 | chessguy | aha. and how do i update it, weavejester? |
| 21:27 | weavejester | Update it? |
| 21:27 | chessguy | weavejester: get a newer version of one of the clojars in it |
| 21:28 | weavejester | You include it as a dependency... |
| 21:28 | weavejester | Unless you're talking about a snapshot version? |
| 21:28 | chessguy | weavejester: what if it's only used as a source of a lein template? |
| 21:28 | amalloy | i'd actually like to see that gist, chessguy, since i don't really believe you have a project with no external dependencies |
| 21:29 | weavejester | Lein templates should always use the latest version |
| 21:30 | chessguy | amalloy: as you wish: https://gist.github.com/arwagner/5409221 |
| 21:31 | amalloy | ugh, pedestal |
| 21:31 | chessguy | what's wrong with pedestal? |
| 21:31 | amalloy | okay, you win. use a project that refuses to use maven for dependency management, and it won't refer to any of your maven cached jars |
| 21:32 | weavejester | Does pedestal not have a project.clj file? |
| 21:32 | chessguy | weavejester: it does |
| 21:32 | amalloy | weavejester: it uses a lein plugin to override the regular dependency-fetching for its sub-projects |
| 21:32 | weavejester | So… what's in the project.clj file? |
| 21:32 | amalloy | or something like that |
| 21:32 | xeqi | chessguy: pedestal is setup with lein-sub projects |
| 21:32 | chessguy | weavejester: but no dependencies |
| 21:33 | weavejester | Ohh |
| 21:33 | weavejester | Well, that's not so bad, probably |
| 21:34 | weavejester | Presumably the sub-projects all have normal dependencies |
| 21:34 | weavejester | Oh yeah, I see |
| 21:34 | chessguy | presumably |
| 21:35 | weavejester | So… what's the issue again? :) |
| 21:35 | chessguy | i'm not sure i remember :) |
| 21:35 | chessguy | oh, yes |
| 21:35 | chessguy | so i want to use pedestal to generate a new application, but i want to make sure i'm generating it with the latest version of all the files |
| 21:36 | chessguy | i suspect that the version in the cache is stale |
| 21:36 | weavejester | It's possible, if it's a snapshot |
| 21:36 | weavejester | I think by default Lein updates snapshots daily? |
| 21:37 | chessguy | i suppose i could just nuke it |
| 21:37 | weavejester | Oh, except it looks like the lein template system doesn't do snapshots, which makes sense |
| 21:38 | weavejester | When I do "lein new pedestal-app foo" it grabs up to version 0.1.5 |
| 21:38 | weavejester | And in github it's 0.1.6-SNAPSHOT |
| 21:38 | weavejester | So if you're looking at the github code expecting something to be there... |
| 21:38 | weavejester | you might be disappointed |
| 21:38 | chessguy | weavejester: ah, so they just haven't put it in clojars yet |
| 21:39 | chessguy | or whatever the heck that site is called |
| 21:39 | weavejester | Right |
| 21:39 | chessguy | gotcha |
| 21:39 | chessguy | can i tell lein to use a template from disk? |
| 21:39 | weavejester | chessguy: What specifically were you looking for? |
| 21:40 | chessguy | weavejester: there was a typo i noticed the other day, and i saw that it was fixed on github. not a big deal, but it would be fun to be on the bleeding edge |
| 21:40 | weavejester | It looks like 0.1.5 is pretty recent... |
| 21:41 | chessguy | plus, i'm trying to learn about the ecosystem, so i'm a little eager to ask questions |
| 21:41 | weavejester | chessguy: Do you mean the #49 pull request typo? |
| 21:41 | weavejester | chessguy: You should have a version later than that |
| 21:42 | weavejester | But that's not in the template code so… I'm not sure why you'd care |
| 21:43 | chessguy | weavejester: no, there was another one |
| 21:43 | chessguy | weavejester: you're right, though, it seems like what i have should be pretty darn new |
| 21:43 | chessguy | i don't know, let me play with it and see |
| 21:44 | weavejester | I gotta head to bed anyway :) |
| 21:44 | chessguy | ok, thanks for your help |
| 21:56 | namespace | So, I've been scouring the docs, and can't figure out a good way to check if the first character of a string is upper case. |
| 21:59 | amalloy | $javadoc Character |
| 21:59 | lazybot | http://docs.oracle.com/javase/6/docs/api/java/lang/Character.html |
| 22:01 | namespace | Thank you. |
| 22:15 | tieTYT | is there a more idiomatic way to do this? (if (= (config destination-button :text) "<Unset>") nil (config destination-button :text)) |
| 22:19 | azkane | tieTYT: i'd use `when` rather than return nil explicitly |
| 22:20 | tieTYT | azkane: actually, this is in a let, can I do that? Can you show me how? |
| 22:20 | tieTYT | in the binding part of a let I mean |
| 22:21 | azkane | so youre binding the return value of that in a let? |
| 22:22 | azkane | i think it still holds as (when (not= (config dest...)) (config ...)) |
| 22:22 | tieTYT | yes |
| 22:22 | tieTYT | ah that's a little better, but I was hoping there's a way to get rid of the DRY violation of that config twice |
| 22:25 | jasonjckn | tieTYT2: when-let |
| 22:25 | jasonjckn | tieTYT: you can always create your own syntax, that's the beauty of lisp |
| 22:26 | azkane | theres a built-in when-let? damn thats why love clojure :) |
| 22:26 | jasonjckn | i thought there was |
| 22:26 | jasonjckn | maybe not |
| 22:26 | jasonjckn | in that case if-let |
| 22:26 | azkane | there is, reading the docs of it atm |
| 22:27 | xeqi | I don't think it will do quite what you want |
| 22:40 | gfredericks | &(partition-all 2 1 "okay") |
| 22:40 | lazybot | ⇒ ((\o \k) (\k \a) (\a \y) (\y)) |
| 22:40 | gfredericks | huh. |
| 22:52 | n_b | Is data.xml deprecated in favour of the xml functionality in core? |
| 22:53 | tieTYT | thanks |
| 22:53 | amalloy | n_b: neither is deprecated, but if anything it's the other way around. xml in core is something rhickey threw together in like a day, five years ago |
| 22:53 | amalloy | data.xml is something that several smart people have spent actual time on, making conforming and performant |
| 22:54 | TimMc | gfredericks: What's up? |
| 22:55 | TimMc | gfredericks: Here's the real head-scratcher: ##(partition 2 1 [] "okay") |
| 22:55 | lazybot | ⇒ ((\o \k) (\k \a) (\a \y) (\y)) |
| 22:55 | n_b | amalloy: I think I'll go with with data.xml then; thanks for the timely, informative answer, as always |
| 22:56 | amalloy | tieTYT: there are some ways to remove that duplication; i'd recommend the pedestrian (let [the-config (config ...)] (when (not= "<Unset>" the-config) the-config)) |
| 22:56 | amalloy | but you could do something silly like (first (remove #{"<Unset>"} [(config ...)])) if you want the people who come after you to be confused |
| 22:57 | tieTYT | amalloy: hah ok |
| 23:21 | patchwork | Best lib for config? |
| 23:21 | patchwork | carica? |
| 23:21 | patchwork | anything else? |
| 23:36 | xeqi | environ is another possiblity |
| 23:36 | namespace | What's the best guide to understanding the Java interop? I'm confused. |
| 23:40 | SegFaultAX | namespace: Anything in particular? |
| 23:41 | namespace | Actually, I think I may have finally figured it out. |
| 23:43 | patchwork | Anyone using luminus? |
| 23:43 | Raynes | ~anyone |
| 23:43 | clojurebot | Just a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..." |
| 23:46 | gdev | does anyone know how I'm more likely to get some help? |
| 23:46 | gdev | ~anyone ? |
| 23:46 | clojurebot | Just a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..." |
| 23:46 | patchwork | I was more looking for firsthand accounts I guess |
| 23:46 | gdev | thanks clojurebot =D |
| 23:47 | patchwork | wanted stories of personal encounters |
| 23:47 | patchwork | impressions, joys, sorrows, dreams |
| 23:47 | namespace | Nope, guess I didn't get it. I'm trying to use the Java method that somebody linked to, but because I haven't really ever used clojure before, I don't know the Java interop. So I read the doc and it says the second operand needs to correspond to a class name when calling a method. |
| 23:47 | patchwork | I guess it is not a concrete question |
| 23:47 | namespace | I figured the code would look like: |
| 23:47 | namespace | (.isUpperCase Character "H") |
| 23:49 | gdev | patchwork, I'm setting up a project now with luminus, i'll let you know tomorrow how i like it |
| 23:49 | xeqi | &(Character/isUpperCase "H") |
| 23:49 | lazybot | java.lang.IllegalArgumentException: No matching method found: isUpperCase |
| 23:50 | xeqi | ah, right |
| 23:50 | namespace | The Java docs claim it is indeed a method. |
| 23:50 | xeqi | &(Character/isUpperCase \H) |
| 23:50 | lazybot | ⇒ true |
| 23:50 | xeqi | string vs character |
| 23:50 | namespace | -_- Really? |
| 23:50 | namespace | Thank you. |
| 23:51 | gdev | &(class \H) |
| 23:51 | lazybot | ⇒ java.lang.Character |
| 23:51 | gdev | &(class "H") |
| 23:51 | lazybot | ⇒ java.lang.String |
| 23:51 | xeqi | patchwork: I don't use luminus, but I've used many of the libraries it brings in |
| 23:52 | gdev | irc is data, data is irc |
| 23:52 | patchwork | xeqi: Yeah it looks like a semi-official confederation of libraries really |
| 23:53 | patchwork | I guess, what are people really talking about when they say "batteries included"? |
| 23:53 | patchwork | What else is a framework supposed to have? |
| 23:55 | talios | batteries included on a web framework would imply a full solution for database access, views/templates, caching, email, scheduling things etc. etc. etc. a raw framework that provides routing/http connectivity - and leaves the rest up to you |
| 23:55 | talios | IMHO |
| 23:56 | gdev | I prefer frameworks to have as little as possible. Do one job well and let me add other libraries that do their jobs well rather than a monolithic thing with half maintained functionality |
| 23:58 | gdev | but that could just be the node.js koolaid talking |
| 23:59 | patchwork | I think of it this way: How much effort is duplicated every time a new project is begun? |
| 23:59 | patchwork | Do I have to craft everything from scratch every time? |