2011-10-18
| 00:17 | Raynes | Strange how they made everything useful about 'doc' private. |
| 00:17 | Raynes | Kind of blows away the whole 'implement with functions and then write a thin layer of macro to make it more convenient'. |
| 00:19 | ibdknox | Raynes: what do you want to do? |
| 00:21 | Raynes | I guess I mostly just wish special-doc wasn't private. |
| 00:24 | Raynes | ,(doc .) |
| 00:24 | clojurebot | I don't understand. |
| 00:24 | Raynes | Didn't figure you would. |
| 00:25 | amalloy | ~source doc |
| 00:26 | Raynes | amalloy: Why aren't you on AIM? |
| 00:26 | Raynes | Oh. Guess it's me that isn't. |
| 00:29 | amalloy | ibdknox: IMO it's hideous that there's all this great logic for encoding information about special forms: which ones are related, what kinds of expressions you can use them in, and where to find more info on clojure.org - but the only "public" way to get at that information is by converting it all into one computer-indigestible string |
| 00:30 | Raynes | Indeed. |
| 00:30 | ibdknox | amalloy: I certainly don't disagree |
| 00:30 | ibdknox | I was just curious what he was up to :) |
| 00:30 | Raynes | ibdknox: Lazybot reimplement's doc in a prettier way for IRC. |
| 00:31 | amalloy | worse, i think, is that you have to have a symbol at macro time - it won't even look anything up for you if you have a var |
| 00:31 | Raynes | Not sure if that apostrophe belonged there. |
| 00:32 | spoon16 | i've got a simple question about (map) |
| 00:32 | ibdknox | spoon16: shoot |
| 00:32 | amalloy | Raynes: Apostrophes don't mean, "WHOA, watch out! HERE COMES AN 'S'!" |
| 00:32 | Raynes | amalloy: I'm aware. |
| 00:32 | spoon16 | I want to (map process-line-func (io/read-lines "file_path")) |
| 00:32 | spoon16 | but I want the resulting vector to exclude nil values |
| 00:32 | spoon16 | my process-line-func is outputting nil if the line is empty |
| 00:32 | amalloy | &(doc keep) |
| 00:32 | lazybot | ⇒ "([f coll]); Returns a lazy sequence of the non-nil results of (f item). Note, this means false return values will be included. f must be free of side-effects." |
| 00:33 | amalloy | and also ##(doc filter) |
| 00:33 | lazybot | ⇒ "([pred coll]); Returns a lazy sequence of the items in coll for which (pred item) returns true. pred must be free of side-effects." |
| 00:34 | spoon16 | link to docs page for that? should I just be looking for keep? |
| 00:34 | Raynes | http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/keep |
| 00:34 | Raynes | The docs are the same. |
| 00:35 | Raynes | &(map identity [nil nil nil]) |
| 00:35 | lazybot | ⇒ (nil nil nil) |
| 00:35 | Raynes | &(keep identity [nil nil nil]) |
| 00:35 | lazybot | ⇒ () |
| 00:35 | Raynes | It's essentially the same thing. Just doesn't bother with nil. |
| 00:35 | spoon16 | I see |
| 00:35 | spoon16 | thanks for the example |
| 00:36 | Raynes | Clojuredocs is good for examples. |
| 00:36 | Raynes | $example keep |
| 00:36 | Raynes | I guess I've forgotten how to use that. |
| 00:36 | Raynes | $examples clojure.core keep |
| 00:36 | Raynes | Perhaps? |
| 00:36 | Raynes | Bah, he hates me. |
| 00:36 | ibdknox | who doesn't? |
| 00:36 | amalloy | Raynes: this is what you get for not writing better docs |
| 00:36 | ibdknox | ~rimshot |
| 00:36 | clojurebot | Badum, *ching* |
| 00:37 | amalloy | if only $examples had an example usage... |
| 00:37 | ibdknox | ohh the irony :p |
| 00:39 | Raynes | Slightly broken at the moment. |
| 00:43 | archaic | I should have been using seesaw waaaaaaaaay earlier. 1000 lines of tangled gui swing -> 400 with real nice modularity |
| 00:44 | Raynes | archaic: I could have told you that! |
| 00:47 | archaic | could you tell me an easy way to integrate with cron? :] |
| 01:03 | spoon16 | how to sort-by a complex key #( ( ( % :value ), ( ( % :child ) :value ) ) |
| 01:03 | spoon16 | output of function in this case would be (5, 2) as an example |
| 01:06 | wiseen | is there a function that will partition the input seq as pair of top two values like : [1 2 3 4 5 6] -> [[1 2] [3 4] [5 6]] - I suspect this should be common since many macros take paired arguments |
| 01:06 | amalloy | spoon16: i assume from your words that you're looking for juxt, but your code is nonsense |
| 01:06 | amalloy | &(doc partition) |
| 01:06 | lazybot | ⇒ "([n coll] [n step coll] [n step pad coll]); Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap. If a pad collection is supplied, use its elements as necessary to compl... https://gist.github.com/1294645 |
| 01:07 | wiseen | amalloy, lol |
| 01:07 | wiseen | tnx |
| 01:07 | amalloy | $findfn 2 [1 2 3 4] [[1 2] [3 4]] |
| 01:07 | lazybot | [clojure.core/split-at clojure.core/partition-all clojure.core/partition] |
| 01:09 | hiredman | ,((juxt (juxt first second) (juxt (comp first rest rest) (comp second rest rest)) [1 2 3 4]) |
| 01:10 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading> |
| 01:10 | spoon16 | amalloy: sorry about the code… still learning so very likely it's completely wrong :) I think you have pointed me in the right direction |
| 01:10 | spoon16 | thanks |
| 01:10 | hiredman | clojurebot: jerl |
| 01:10 | clojurebot | I don't understand. |
| 01:10 | hiredman | ,((juxt (juxt first second) (juxt (comp first rest rest) (comp second rest rest))) (range 1 5)) |
| 01:10 | clojurebot | [[1 2] [3 4]] |
| 01:10 | amalloy | hiredman: haha very classy |
| 01:11 | amalloy | you just need to work a sort-by in there so your code answers both of their questions entirely |
| 01:13 | hiredman | ,((comp (juxt (juxt first second) (juxt (comp first rest rest) (comp second rest rest))) (partial sort-by identity)) (range 1 5)) |
| 01:13 | clojurebot | [[1 2] [3 4]] |
| 01:29 | MGT | hi |
| 01:31 | novitk | Hi, I have some really wicked bahaviour with clojure.java.shell |
| 01:31 | novitk | novitk@max:~/tmp$ cat shprob.clj (use '[clojure.java.shell :as shell]) (println (:out (shell/sh "ls" "-l"))) novitk@max:~/tmp$ time java -jar ../clojure-1.3.0/clojure-1.3.0.jar shprob.clj total 20 -rw-r--r-- 1 novitk novitk 18 2011-10-18 01:16 hello.clj drwxr-xr-x 2 novitk novitk 4096 2011-10-02 12:05 sdd1 -rw-r--r-- 1 novitk novitk 76 2011-10-18 01:17 shprob.clj -rw-r--r-- 1 novitk novitk 75 2011-10-18 01:07 shprob.clj~ d |
| 01:32 | novitk | basically if I use it the jvm waits for over a minute to shutdown |
| 01:32 | amalloy | novitk: futures and the agent threadpool |
| 01:32 | novitk | this is on both ubuntu and win |
| 01:33 | novitk | shell is using agents? |
| 01:33 | amalloy | sh spins up some threads to support piped io |
| 01:33 | amalloy | and futures use a threadpool, which doesn't get automatically shut down |
| 01:35 | novitk | thx amalloy, will research |
| 01:36 | ibdknox | man, I should write my doc strings as I go instead of waiting until the end |
| 01:37 | amalloy | ibdknox: (defn munge "Does some kind of string manipulation, honestly I don't remember what kind and the code is a mess." [x] ...)? |
| 01:37 | ibdknox | haha |
| 01:37 | ibdknox | more that writing 180 lines of docs all at once is incredibly boring |
| 01:38 | ibdknox | https://github.com/ibdknox/Korma/commit/0b9193fc26f05d758eed7349e3791eac02f4dcee |
| 01:41 | tolstoy | Is it possible to have multiple namespaces in a single file (when running as leon run, for instance)? |
| 01:42 | amalloy | ibdknox: https://github.com/ibdknox/Korma/commit/0b9193fc26f05d758eed7349e3791eac02f4dcee#L1L155 - you were too weak to do doc-only |
| 01:43 | tolstoy | (ns util) (some-forms) (ns my-app.core) (defn -main [& args] (util/foo)) |
| 01:43 | tolstoy | Seems like that was possible back in the Clojure 1.1ish days (last time I used it). |
| 01:43 | ibdknox | amalloy: it's true... don't tell anyone :p |
| 01:44 | ibdknox | tolstoy: you can have multiple ns's in a single file, but require won't do the right thing |
| 01:44 | tolstoy | How about use? |
| 01:44 | ibdknox | tolstoy: use is basically just require + refer |
| 01:45 | tolstoy | ibdknox: So, basically, no? (I don't mind, just don't want to rathole on this.) |
| 01:45 | ibdknox | tolstoy: yeah, it's not idiomatic and generally not a good idea in the first place, so no one went out of their way to make it easy :) |
| 01:45 | tolstoy | I only really want to do it just for initial dev. |
| 01:46 | amalloy | tolstoy: it's certainly possible. you just can't require a namespace unless it's in the file it "should" be |
| 01:48 | tolstoy | Ah! I got it to work. amalloy: Okay, I got you on that "require" part of it. I'm just using it as a way to keep bunches of functions sectioned off while I figure out what I'm doing. |
| 01:48 | amalloy | tolstoy: if your OS was built after 1950, you have an even better way, though: put them in separate files :P |
| 01:49 | ibdknox | mine was built in 1949. |
| 01:49 | tolstoy | amalloy: Heh. Next you'll be suggesting I can just flip from buffer to buffer in this editor-type-thing. |
| 01:50 | ibdknox | still runs like the day I bought her. |
| 01:50 | amalloy | ibdknox: don't make me oil up the old Analytical Engine. let's not make this a contest |
| 01:50 | ibdknox | lol |
| 01:51 | spoon16 | how can I combine a list of vectors ([] [] []) into a single vector… or list? |
| 01:52 | ibdknox | ,(doc concat) |
| 01:52 | clojurebot | "([] [x] [x y] [x y & zs]); Returns a lazy seq representing the concatenation of the elements in the supplied colls." |
| 01:52 | ibdknox | ,(doc reduce) |
| 01:52 | clojurebot | "([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val i... |
| 01:54 | archaic | ,(source filter) |
| 01:54 | clojurebot | Source not found |
| 01:54 | tolstoy | Googled in "wabbitmq" and google won't believe me, insists I mean RabbitMQ. (Alas, wabbitmq seems abandoned.) |
| 02:54 | archaic | trying to get command-line interface working, I can compile cmd_line_test fine, I can run it using lein run, but java -cp . cmd_line_test gives a NoClassDefFoundError from the projects root directory .. (the 4 .class files main,init,etc are in the /classes folder) any ideas? |
| 02:55 | tolstoy | Hm. That happened to me today (new to Clojure after a couple of years away from it). |
| 02:55 | tolstoy | I solved it by adding (:gen-class) to the ns declaration where my main method was. |
| 02:55 | tolstoy | That was so that my uberjar would be executable. |
| 02:56 | archaic | its there ;| |
| 02:56 | tolstoy | (java -jar myapp.jar) |
| 02:56 | tolstoy | Drat! |
| 02:58 | tolstoy | which class is not found? is clojure.jar on the class path? |
| 03:00 | archaic | cmd_line_test is not found, clojure-1.3.0.jar is in lib/ |
| 03:32 | Blkt | good morning everyone :D |
| 03:43 | spoon16 | how do I debug this? |
| 03:43 | spoon16 | user=> lines |
| 03:43 | spoon16 | ("43 70 27" "3 18 24" "65 99 45" "20 39 26" "45 74 26" "10 28 20" "78 97 23" "0 9 22" "") |
| 03:43 | spoon16 | user=> (map #( (println %) ) lines) |
| 03:43 | spoon16 | (43 70 27 |
| 03:43 | spoon16 | java.lang.NullPointerException |
| 03:43 | spoon16 | sorry, didn't mean to paste that many lines |
| 03:45 | Fossi | ,(map #( println % ) ("43 70 27" "3 18 24" "65 99 45" "20 39 26" "45 74 26" "10 28 20" "78 97 23" "0 9 22" "") ) |
| 03:45 | tolstoy | spoon16: Not sure. But does (map println lines) work? |
| 03:45 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn> |
| 03:45 | scottj | spoon16: #(println %) instead of #((println %)) |
| 03:45 | scottj | println returns nil and you can't call nil as a function. so you have (println %) returns nil and then #(nil) calls it |
| 03:46 | spoon16 | i see |
| 03:46 | spoon16 | thanks |
| 03:46 | scottj | and normally you don't use map for side effects, but doseq |
| 03:46 | spoon16 | yeah, I'm trying to debug some other issue |
| 03:47 | spoon16 | not actually wanting to print |
| 03:47 | scottj | but if you like map, realize it's lazy and you might need to dorun or doall it |
| 03:47 | spoon16 | it's the extra () |
| 03:47 | Fossi | ,(map #( println % ) '("43 70 27" "3 18 24" "65 99 45" "20 39 26" "45 74 26" "10 28 20" "78 97 23" "0 9 22" "") ) |
| 03:47 | clojurebot | (43 70 27 |
| 03:47 | clojurebot | 3 18 24 |
| 03:47 | clojurebot | nil 65 99 45 |
| 03:47 | clojurebot | nil 20 39 26 |
| 03:47 | clojurebot | nil 45 74 26 |
| 03:47 | clojurebot | nil 10 28 20 |
| 03:47 | clojurebot | nil 78 97 23 |
| 03:47 | clojurebot | ...) |
| 03:48 | Fossi | ups :> |
| 03:48 | scottj | spoon16: btw you can (map println lines), no need to wrap in function |
| 03:48 | Fossi | ,(map println '("43 70 27" "3 18 24" "65 99 45") ) |
| 03:48 | clojurebot | (43 70 27 |
| 03:48 | clojurebot | 3 18 24 |
| 03:48 | clojurebot | nil 65 99 45 |
| 03:48 | clojurebot | nil nil) |
| 03:48 | Fossi | lots of nils in there as well ;) |
| 03:49 | scottj | I think the return value and output get interleaved |
| 03:49 | scottj | I think the result is just (nil nil nil) |
| 03:50 | tolstoy | ,(doseq [x '("43 70 27" "3 18 24" "65 99 45" "20 39 26" "45 74 26" "10 28 20" "78 97 23" "0 9 22" "")] (println x)) |
| 03:50 | clojurebot | 43 70 27 |
| 03:50 | clojurebot | 3 18 24 |
| 03:50 | clojurebot | 65 99 45 |
| 03:50 | clojurebot | 20 39 26 |
| 03:50 | clojurebot | 45 74 26 |
| 03:50 | clojurebot | 10 28 20 |
| 03:50 | clojurebot | 78 97 23 |
| 03:50 | clojurebot | 0 9 22 |
| 03:50 | tolstoy | scottj: ftw |
| 04:02 | ejackson | morning all |
| 04:03 | scottj | Raynes: maybe put weather in the ororo description so it shows up in searches on clojars |
| 04:39 | Raynes | scottj: Good idea. Done. |
| 04:39 | spoon16 | best way to iterate over a vector of structs and (assoc struct-instance :index i)? |
| 04:40 | Raynes | Step one is stop using structs. They've been deprecated for a long time. |
| 04:41 | Raynes | http://clojure.org/datatypes you probably want to use defrecord instead. |
| 04:41 | spoon16 | what should I use instead… I was just playing with ants.clj and they are used there because (I guess) the underlying map keys are not reqused |
| 04:41 | Raynes | ants.clj was written in Clojure 1.0, IIRC. |
| 04:41 | spoon16 | yeah, I'm sure you are right |
| 04:41 | spoon16 | it's just what I was looking at |
| 04:42 | Raynes | Not criticizing you. Just making sure you know. :) |
| 04:42 | spoon16 | I have a vector where isntances in the vector point to arbitrary other instances in the same vector. When I encounter an instance in the vector that has a pointer to an arbitrary instance I need to navigate that reference and identify the index in the vector that reference owns |
| 04:43 | spoon16 | so how can I iterate over the vector and add an :index property to every instance in the vector? |
| 04:47 | scottj | Raynes: also at least single example api fn call in the readme would have been niced |
| 04:49 | clgv | spoon16: like &(vec (map-indexed (hash-map :value %2 :index %1) [10 11 12])) |
| 04:49 | clgv | ,(vec (map-indexed (hash-map :value %2 :index %1) [10 11 12])) |
| 04:49 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: %2 in this context, compiling:(NO_SOURCE_PATH:0)> |
| 04:49 | clgv | ,(vec (map-indexed #(hash-map :value %2 :index %1) [10 11 12])) |
| 04:49 | clojurebot | [{:index 0, :value 10} {:index 1, :value 11} {:index 2, :value 12}] |
| 04:50 | spoon16 | nice |
| 04:50 | spoon16 | thanks |
| 04:50 | clgv | it's not really "adding" but creating a new vector with those maps. but it does what you described. |
| 04:52 | Raynes | scottj: I thought the documentation was pretty clear. It is extremely simple. Everything take two arguments except for history. |
| 04:52 | spoon16 | yeah, I get it |
| 04:52 | spoon16 | thats what I wanted |
| 04:52 | Raynes | scottj: But if you think it'd be helpful, I'll add an example call. |
| 04:52 | scottj | Raynes: having an example code means you don't have to read the documentation :) |
| 04:53 | Raynes | Evil. |
| 04:53 | clgv | +1 raynes. skipping reading the docu sounds like a straight way to hell^^ |
| 04:54 | Raynes | clgv: In this case, not really. Like I said, all of the API methods (except for that damn history one) are exactly the same. One example actually does the trick here. |
| 04:54 | scottj | (conditions api-key "22206") or something |
| 04:54 | Raynes | Precisely. |
| 04:54 | scottj | three words instead of three paragraphs :) |
| 04:55 | clgv | Raynes: what lib are you talking about? |
| 04:55 | Raynes | clgv: http://github.com/Raynes/ororo |
| 04:57 | clgv | Raynes: hmm interesting. they have weather data for my city as well :) |
| 04:59 | Raynes | scottj: Added a couple of examples. |
| 05:00 | Raynes | I'll extend that to allow for all sorts of things to be passed. Maps, sequential collections, and strings of various lovely formats. |
| 05:00 | Raynes | You can pass a string like "state/city" right now. |
| 05:01 | scottj | it is interesting that the state position can also be country |
| 05:01 | Raynes | That API can do all kinds of fun things. lazybot will get a bunch of weather features as soon as I get around to writing a plugin. |
| 05:01 | Raynes | Yeah, that's useful. |
| 05:03 | scottj | where does the name come from? |
| 05:04 | Raynes | scottj: The first name of Storm from XMen. |
| 05:05 | scottj | ahh, I'm clueless about xmen, I think I was the only one in the theater of this last movie that didn't know magneto was going to be bad |
| 05:06 | Raynes | Heh. amalloy_ actually led me to the name. I didn't actually think to use it until he mentioned Storm. |
| 08:00 | lnostdal_ | does a print function that does not add spaces exist? |
| 08:16 | clgv | lnostdal_: spaces left and right of characters or also spaces in-between characters |
| 08:27 | fdaoud | raek, gfredericks: remember our little conversation yesterday.. |
| 08:28 | fdaoud | I found the missing piece of my puzzle: resolve |
| 08:28 | fdaoud | ,((resolve (first '(+ 3 4))) 38 4) |
| 08:28 | clojurebot | 42 |
| 08:30 | tordmor | ,(doc resolve) |
| 08:30 | clojurebot | "([sym] [env sym]); same as (ns-resolve *ns* symbol) or (ns-resolve *ns* &env symbol)" |
| 08:32 | fdaoud | 4clojure doesn't allow resolve either! bah! |
| 08:59 | antares_ | hey guys. I am seeing this exception coming from Leiningen (or so I think): https://gist.github.com/12ee8a548a46431674e9 — is it a known problem? |
| 09:04 | kij | |
| 10:16 | clgv | antares: afaik it is a problem with AOT compiled code under clojure 1.2 that you now want to use when building a clojure 1.3 project |
| 10:54 | semperos | trying to learn pallet by using a local "stub" provider with jclouds; anyone know of any good resources/examples I could use as a reference to get things working? |
| 10:55 | semperos | or perhaps node-list is the appropriate one for local playing... |
| 11:01 | jcromartie | I propose that any embedded Lisp s-expression-based query language be called "SexQL" |
| 11:18 | SLi | Looking to buy Joy of Clojure book without killing trees, since I'd rather read it on my Kindle anyway... And the situation seems quite confusing. Apparently there's a Kindle version, but not in Amazon? Also Manning website says "No matter where you buy the pBook—whether from the Manning website, another online store, or in a regular bookshop—you can now get the eBook at no extra charge. To register your pBook, you will need information from the book's inse |
| 11:19 | SLi | Of course I could just order the paper version, get the ebook version and sell the paper version... Still would rather save the hassle. :) |
| 11:40 | scgilardi | you can buy the ebook in kindle format from this page: http://www.manning.com/fogus/ . what's confusing? |
| 11:47 | joegallo | technomancy: i'm trying to find the source for http://clojars.org/server-socket, but google is denying me -- link? |
| 11:49 | cemerick | Jeez, RSVPs are full for ClojureNYC tomorrow. |
| 11:57 | dnolen | cemerick: nice! I strangely sense that the interest Clojure in NYC is starting to heat up. |
| 11:58 | cemerick | Now if Boston can get a little warmer. Decidedly chilly over there, surprisingly. |
| 11:58 | dnolen | will be giving a presentation tonight at Gilt Groupe, and then another before the Conj at Hacker School - a fun thing hosted at Spotify's offices. |
| 11:58 | cemerick | dnolen: good luck at the Gilt Group thing tomorrow, btw :-) |
| 11:59 | babilen | Anybody knows what "Houser EK" references in Joy of Clojure (10.7)? It is about exception handling in Clojure and the Text is "..and it might be better to explore other possibilities (Houser EK)" |
| 11:59 | dnolen | cemerick: thanks, unfortunate they're happening at the same time! But I'll catch it at the Conj :) |
| 11:59 | babilen | 10.7.4 to be precise |
| 11:59 | cemerick | dnolen: it'll be much better by then, for sure |
| 12:00 | cemerick | I got behind on the underlying project a bit; having this dry run is forcing me to get back to it |
| 12:00 | zerokarmaleft | babilen: clojure.contrib.error-kit, i believe |
| 12:02 | zerokarmaleft | babilen: http://richhickey.github.com/clojure-contrib/error-kit-api.html |
| 12:02 | lazybot | Nooooo, that's so out of date! Please see instead http://clojure.github.com/clojure-contrib/error-kit-api.html and try to stop linking to rich's repo. |
| 12:02 | zerokarmaleft | bargle |
| 12:02 | babilen | zerokarmaleft: Ah, ok. Thank you -- I just wanted to explore those "other possibilities" -- What else are good ones to take a look at? |
| 12:03 | babilen | zerokarmaleft: That reference was completely lost on me |
| 12:03 | mrsipan | is there a way to declare custom exceptions for error handling? |
| 12:04 | mrsipan | I have heard about conditions, but have no idea what is its relation with exceptions |
| 12:04 | babilen | mrsipan: Yes, either use gen-class or "explore other possibilities" such as http://clojure.github.com/clojure-contrib/error-kit-api.html |
| 12:05 | babilen | ;) |
| 12:05 | mrsipan | babilen, thanks |
| 12:05 | raek | babilen: check out "Slingshot" |
| 12:06 | raek | babilen: https://github.com/scgilardi/slingshot |
| 12:06 | babilen | raek: I'll take a look. And while we are in the "take a look" phase ... midje or lazytest or something else? |
| 12:06 | seancorfield | the consensus seems to be that none of the exception handling contrib namespaces will be migrated to new contrib so the "official" recommendation for now is to look at slingshot... |
| 12:07 | babilen | seancorfield: Thank you |
| 12:07 | raek | I think slingshot has informally taken the place of error-kit and condition |
| 12:07 | raek | ah, what seancorfield said... :-) |
| 12:08 | seancorfield | see http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go for more detail on old contrib and new contrib (and what's effectively going away for want of an active maintainer) |
| 12:24 | TeXnomancy | joegallo: oh no, I forgot to push the source |
| 12:42 | duck1123 | babilen: re Midje vs Lazytest, I've used both, and both are very nice, but lazytest was limited in the types of "fixtures" that could be applied |
| 12:42 | duck1123 | I found myself needing 'around' and couldn't pull it off easily in lazytest |
| 12:50 | technomancy | joegallo: https://github.com/technomancy/server-socket |
| 12:50 | joegallo | rock out, thanks man |
| 12:51 | technomancy | np |
| 12:51 | technomancy | I emailed Craig McDaniel; he misses working in Clojure =( |
| 12:51 | technomancy | (original author of server-socket) |
| 12:51 | ejackson | eep, I still use good ole' clojure.test. I feel old |
| 12:52 | technomancy | leiningen teaches clojure.test some new tricks =) |
| 12:54 | pjstadig | i sooo want to say "real men don't write tests", but maybe i shouldn't :) |
| 12:55 | pjstadig | which of course would be a joke, so don't get worked up about it |
| 12:58 | S11001001 | scgilardi: I'm thinking about this % thing again; mightn't it be safer to wrap in `(let [~'% (:object ~'&throw-context)] ...) instead of doing the prewalk-replace? |
| 12:58 | S11001001 | ls |
| 12:58 | S11001001 | (benefits of erc) |
| 13:18 | andrewclegg | ok, stupid moment. how do you define a global that maps to a particular instance of a java enum? |
| 13:18 | andrewclegg | I tried like this: (def track ResourceType/TRACK) |
| 13:18 | andrewclegg | ResourceType cannot be cast to clojure.lang.IFn :-( |
| 13:19 | andrewclegg | could make them into 0-arg functions but that seems like missing the point |
| 13:20 | aaelony | What is the best way to write a large lazyseq to a file? I am experimenting with spit, but not sure for to force it to output to file http://pastie.org/2718820 |
| 13:22 | raek | aaelony: (with-open [out (io/writer "filename.txt")] (binding [*out* out] (doseq [line lines] (println line)))) |
| 13:22 | raek | where io is clojure.java.io |
| 13:22 | aaelony | raek: thanks very much :) |
| 13:23 | raek | andrewclegg: that should work |
| 13:23 | raek | andrewclegg: (def green java.awt.Color/GREEN) works in my repl |
| 13:24 | raek | I think the problem is elsewhere |
| 13:24 | andrewclegg | probably pilot error, hang on |
| 13:25 | raek | "ResourceType cannot be cast to clojure.lang.IFn" seems to indicate that you try to use the value as a 0-arg function, though |
| 13:25 | andrewclegg | yeah, sorry, I had some stray parens around it where I was using it |
| 13:31 | timvisher | i'm trying to turn a zipfile into a seq of byte[] using util.zip. A) is there an easier library to work with? and B) how do i work with `while` idioms in clojure? |
| 13:32 | timvisher | B being only relevant if there isn't a better library |
| 13:36 | joegallo | ,(doc while) |
| 13:36 | clojurebot | "([test & body]); Repeatedly executes body while test expression is true. Presumes some side-effect will cause test to become false/nil. Returns nil" |
| 13:37 | timvisher | joegallo: /me smacks foreheak. RTFM! ;) |
| 13:37 | joegallo | np, it's an easy one to miss |
| 13:37 | timvisher | god, this api is atrocious |
| 13:38 | timvisher | it doesn't even implement Iterable |
| 13:58 | spoon16 | I'm playing around in the REPL and am getting 'java.lang.NullPointerException (NO_SOURCE_FILE:0)' |
| 13:58 | spoon16 | is there some way to get a more meaningful stack trace? |
| 13:58 | hiredman | (.printStackTrace *e) |
| 13:58 | hiredman | *e is the last uncaught exception thrown |
| 13:59 | spoon16 | thanks |
| 13:59 | bhenry | where is show? |
| 14:00 | bhenry | i.e. what namespace |
| 14:00 | hiredman | clojure.repl maybe |
| 14:00 | hiredman | ,(require 'clojure.repl) |
| 14:00 | clojurebot | nil |
| 14:00 | hiredman | ,(get (ns-publics (create-ns 'clojure.repl)) 'show) |
| 14:00 | clojurebot | nil |
| 14:01 | bhenry | it's not there. i thought it would be. |
| 14:01 | hiredman | ,(ns-publics (create-ns 'clojure.repl)) |
| 14:01 | clojurebot | {source #'clojure.repl/source, stack-element-str #'clojure.repl/stack-element-str, set-break-handler! #'clojure.repl/set-break-handler!, find-doc #'clojure.repl/find-doc, thread-stopper #'clojure.repl/thread-stopper, ...} |
| 14:01 | hiredman | :/ |
| 14:01 | hiredman | possibly some clojure.tools.* |
| 14:02 | drewr | bhenry: it's still only in clojure.contrib.repl-utils |
| 14:02 | bhenry | cool drewr thanks |
| 14:02 | drewr | I have to keep [org.clojure.contrib/repl-utils "1.3.0-alpha4"] around *just* for that |
| 14:02 | drewr | which prints earmuff warnings every time I compile the code :'( |
| 14:04 | hiredman | maybe the plan is to rewrite it on top of clojure.reflect.java |
| 14:05 | hiredman | clojure.reflect/reflect maybe similar to show |
| 14:10 | hiredman | would be interesting to have a library that takes in something like reflect returns and generates classes |
| 14:12 | timvisher | is there any way to represent this idiom in clojure? `while((entry = zis.getNextEntry()) != null) {` |
| 14:12 | timvisher | i'm aware of `while` but I can't figure out how to mash this in there |
| 14:13 | nickmbailey | sounds kind of like you just want 'map' |
| 14:13 | Bronsa | timvisher: usually to cicly through all the elements of a sequence in clojure doseq is used |
| 14:13 | Bronsa | *cicle |
| 14:13 | timvisher | yes, but the problem is that i'm not dealing with a seqable api |
| 14:13 | timvisher | http://java.sun.com/developer/technicalArticles/Programming/compression/ |
| 14:15 | timvisher | and ZipFile. doesn't allow for a URI |
| 14:15 | timvisher | so I need to use their ZipInputStream. but that requires that `while` idiom |
| 14:15 | timvisher | i'm trying to avoid setting a var or something but i'm guessing i'm going to have to |
| 14:16 | S11001001 | timvisher: you need loop, not while |
| 14:16 | timvisher | maybe store the result of .getNextEntry in an atom and swap at the end of the function? |
| 14:17 | timvisher | with a `(recur (.getNextEntry zis))`? |
| 14:21 | timvisher | well, i suppose that none of these zip files will _ever_ be big enough to blow the stack. ;) |
| 14:23 | nickmbailey | loop/recur doesn't consume stack space |
| 14:24 | timvisher | true true |
| 14:27 | jkkramer | timvisher: http://stackoverflow.com/questions/5419125/using-java-api-from-clojure-reading-zip-file |
| 14:33 | amalloy | timvisher: you can (take-while identity (repeatedly #(.getNextEntry zis))) |
| 14:33 | amalloy | and then you have a seq and can stop messing with this mutability stuff |
| 14:36 | timvisher | jkkramer, amalloy: thanks for the pointers! |
| 14:36 | timvisher | unfortunately, this api seems to be particularly functionally resistant |
| 14:36 | timvisher | just having a seq of zipentries won't do it, because I can't then turn those into byte arrays |
| 14:37 | timvisher | i'm essentially trying to coerce the zipfile into a seq of input-streamables |
| 14:37 | timvisher | but a ZipEntry doesn't expose anything that lets me do that |
| 14:38 | amalloy | $javadoc java.util.zip.ZipEntry |
| 14:38 | lazybot | http://download.oracle.com/javase/6/docs/api/java/util/zip/ZipEntry.html |
| 14:40 | amalloy | timvisher: so you have to call .getCompressedSize on each entry, and then read that large a byte[] from the input stream? j.u.zip is even worse than i remember |
| 14:41 | timvisher | it's crazy bad. :) |
| 14:41 | timvisher | i'd expect that to be the case (.getCompressedSize), but it returns zero for a directory entry |
| 14:42 | timvisher | which is incorrect, IRRC |
| 14:42 | amalloy | timvisher: i think it's probably right? |
| 14:43 | timvisher | ah |
| 14:43 | timvisher | well, this is my first forray into zips so i'm probably the wrong one here |
| 14:46 | timvisher | as a side question, :use doesn't expose the namespace's functions as native functions to others who :require the ns. Is there a way to do that? |
| 14:47 | timvisher | i.e. I have a ns that builds on the functionality of another library, but I'd like all of the functions of the other library to be exposed to anyone using mine |
| 14:47 | timvisher | so far, i've been duplicating defns and requiring the other ns |
| 14:47 | timvisher | which, ahem, is terrible |
| 14:49 | amalloy | timvisher: that's a frowned-on activity |
| 14:51 | timvisher | which part? |
| 14:52 | timvisher | amalloy: |
| 14:52 | amalloy | timvisher: re-exposing other functions as if they were yours |
| 14:52 | timvisher | ah |
| 14:53 | timvisher | so, being that it's frowned upon, i suppose clojure provides no way to do it? |
| 14:53 | amalloy | there are macros to do that in contrib, like defalias and immigrate (or maybe that's in a third-party lib?), but there's definitely nothing in core |
| 14:53 | timvisher | oh well, i'll have to figure a different model then. :) |
| 14:54 | amalloy | timvisher: it's probably simplest to just have your users (:use [highlevel :only [foo bar]]) (:require [lowlevel :as hack]) or something |
| 14:55 | timvisher | ultimately, I was attempting to have a little sandbox for improving the library before contributing back, but that was before I understod lein a little better. I could be hacking on it and just publishing locally |
| 14:55 | timvisher | that's probably the way I want to go |
| 14:59 | Raynes | Did somebody say… SANDBOX!?!?! |
| 15:00 | Raynes | http://github.com/flatland/clojail |
| 15:00 | Raynes | Aw, not that kind of sandbox. |
| 15:00 | timvisher | :) |
| 15:01 | timvisher | you're enthusiasm is duly noted, though. |
| 15:48 | spoon16 | I know that I am doing it wrong… but I'm having a bit of a hard time identifying the right way to solve this |
| 15:48 | spoon16 | ,(map-indexed #(assoc %2 :index %1) (let [b { :p 19 } a { :p 8 :s b }] [a b])) |
| 15:48 | clojurebot | ({:index 0, :p 8, :s {:p 19}} {:index 1, :p 19}) |
| 15:48 | spoon16 | I want :s on the the first item in the vector to have :index 1 |
| 15:49 | spoon16 | do I need to use refs/vars or some means of indirection when building the map? |
| 15:49 | spoon16 | s/vector/list |
| 15:52 | llasram` | spoon16: What's the larger problem you're trying to solve? |
| 15:54 | spoon16 | just messing around… I have a list of objects and any object may reference any other object… but I want to be able to identify the index of the item that I land on when I navigate one of those relationships |
| 15:55 | spoon16 | I can use map-indexed to rebuild the list with each object having a :index property… but that doesn't update the random reference… that random reference still points at the version of the object with no :index annotation |
| 15:56 | technomancy | I would argue that defalias is actually quite useful in deprecation scenarios. |
| 15:58 | spoon16 | here is a slightly compact version |
| 15:58 | spoon16 | ,(map-indexed #(assoc %2 :index %1) (let [b { } a {:s b}] [a b])) |
| 15:58 | clojurebot | ({:index 0, :s {}} {:index 1}) |
| 16:01 | wwmorgan | I have some Thai strings that show up in my lein repl as ??? ?????. I've installed rlwrap but I still just get the question marks. How can I make the right characters appear? |
| 16:01 | dnolen | http://stackoverflow.com/questions/7812635/how-do-i-effectively-manage-a-clojure-code-base |
| 16:03 | llasram` | spoon16: how about: |
| 16:03 | spoon16 | I want (= (-> (first t) :s :index) (-> (second t) :index)) to be true |
| 16:03 | llasram` | ,(let [b { }, a {:s b}, items [a b], index-of (reduce (fn [m [x i]] (assoc m i x)) {} (map-indexed vector items))] [(index-of a) (index-of b)]) |
| 16:03 | clojurebot | [0 1] |
| 16:03 | technomancy | wwmorgan: probably a locale issue; could it be stuck on macroman? |
| 16:03 | spoon16 | llasram`: let me play with it |
| 16:04 | llasram` | spoon16: Otherwise... Well, I don't that what you're trying to do is possible with immutable data structures |
| 16:04 | spoon16 | llasram`: it is definately possible that I'm doing it completely wrong :) |
| 16:04 | fliebel | dnolen: hmm |
| 16:05 | todun | is there a simple way to test for numbers in clojure? thanks. |
| 16:06 | dnolen | ,(number? 1) |
| 16:06 | clojurebot | true |
| 16:06 | dnolen | ,(number? 1.5) |
| 16:06 | clojurebot | true |
| 16:06 | todun | dnolen: simple. elegant. thanks :) |
| 16:07 | wwmorgan | technomancy: actually I just tried a Thai string literal and it worked. I think the bug is somewhere in the file IO that I'm doing (slurp?). Thanks! |
| 16:07 | todun | is there a way to filter out the elements of a seq without removing the opening and closing braces? |
| 16:07 | raek | wwmorgan: which encoding is the file in? |
| 16:07 | raek | slurp uses UTF-8 by default |
| 16:08 | llasram` | todun: ex? |
| 16:08 | todun | llasram: (1 2 3) becomes () |
| 16:09 | dnolen | ,(empty '(1 2 3)) |
| 16:09 | clojurebot | () |
| 16:09 | dnolen | ,(empty '{1 2 3 4}) |
| 16:09 | clojurebot | {} |
| 16:09 | wwmorgan | raek: it is UTF-8. Hmm |
| 16:09 | todun | dnolen: woah! clojure can do that? thanks. I googled for stuff like that and turned up empty. |
| 16:09 | todun | dnolen: thanks again. |
| 16:09 | bhenry | how can i convert some java like this to clojure https://gist.github.com/777d5bbe558a77fef033 |
| 16:09 | llasram` | Right, that's what dnolen said (*rimshot*) |
| 16:11 | fliebel | bhenry: There is a JDBC i new contrib. Maybe that helps? |
| 16:11 | raek | wwmorgan: can you try to evaluate (seq "åäö") in your repl to test that it's set up correctly? |
| 16:11 | bhenry | fliebel: solid. i'll head that way. |
| 16:11 | raek | wwmorgan: it should evaluate to (\å \ä \ö) |
| 16:11 | gtrak | ,(seq "åäö") |
| 16:11 | clojurebot | (\� \� \�) |
| 16:11 | wwmorgan | raek: yep. I get the ?s |
| 16:11 | fliebel | &(seq "åäö") |
| 16:11 | lazybot | ⇒ (\å \ä \ö) |
| 16:12 | fliebel | lazybot wins |
| 16:12 | raek | wwmorgan: what letters did you see from me? latin letters with diacritics or questionmarks? |
| 16:12 | wwmorgan | raek: from you I see the latin letters with diacritics |
| 16:13 | raek | you should see the same thee letters in the result in the repl |
| 16:13 | raek | *three |
| 16:13 | raek | wwmorgan: did you see letters or questionmarks in the repl output? |
| 16:15 | wwmorgan | raek: I got question marks. But if I do (apply str (seq "åäö")) then I get the right thing again |
| 16:15 | raek | wwmorgan: then your terminal is not configured right. |
| 16:16 | raek | what OS do you use? |
| 16:16 | llasram` | i stick to a subset of english which can be represented in five bits |
| 16:16 | wwmorgan | raek: mac os x |
| 16:18 | raek | wwmorgan: ok, there is a problem with java in os x. it's incorrectly configured to use MacRoman as the default encoding (but the encoding really used is actually UTF-8) |
| 16:19 | technomancy | heh; macroman |
| 16:19 | fliebel | Wow, my input is even more exotic: (\? \? \? \? \? \?) |
| 16:19 | raek | now, there should be a way to set a certain java property to override that |
| 16:19 | wwmorgan | raek: aha. So I want to tell leiningen to use a JVM opt to use UTF-8 instead |
| 16:20 | fliebel | -XXDoNotUseExoticEncoing |
| 16:20 | raek | technomancy: what is the preferred way to set a java property globally in lein? |
| 16:20 | technomancy | raek: export JVM_OPTS if you want it to apply across all projects. |
| 16:21 | wwmorgan | yep. Invoking java with -Dfile.encoding=UTF-8 seems to do it |
| 16:21 | raek | something like this? --> export JVM_OPTS=-Dfile.encoding=UTF-8 |
| 16:22 | raek | wwmorgan: hopefully there should be a way to set that environment variable globally in os x |
| 16:22 | technomancy | raek: sure |
| 16:22 | raek | wwmorgan: did the thai text work too after this? |
| 16:22 | wwmorgan | raek, technomancy: thanks! Everything looks good now |
| 16:22 | technomancy | unfortunately OS X makes it a pain to set environment variables that apply globallye. |
| 16:23 | jriddy | is there a more obvious way to coerce to a bool than #(if % true false) ? |
| 16:23 | raek | jriddy: 'boolean' |
| 16:23 | jriddy | ,(boolean 1) |
| 16:23 | talios | technomancy: did michael neale from cloudbees get a hold of you? |
| 16:23 | clojurebot | true |
| 16:23 | jriddy | thx |
| 16:26 | antares_ | technomancy: hi! what's the right place for leiningen questions? |
| 16:26 | Raynes | antares_: Here is fine. |
| 16:27 | antares_ | I am getting the following exception with 1.6.1.1: https://gist.github.com/12ee8a548a46431674e9 |
| 16:27 | Raynes | http://groups.google.com/group/leiningen There is also the mailing list. |
| 16:27 | talios | wb splitters |
| 16:27 | Raynes | If nobody answers you here, go ahead and post to the mailing list. |
| 16:27 | antares_ | if I remove lib/dev, things work fine until lein deps downloads dependencies again |
| 16:28 | antares_ | I managed to build 1.6.2-SNAPSHOT and replace my ~/.lein/self-installs/* jar with it, now it works fine |
| 16:28 | technomancy | talios: I don't think so. was that over email or what? |
| 16:29 | technomancy | antares_: probably a bad dev-dependency ruining it for everyone |
| 16:29 | talios | technomancy: irc, I pointed him here - he's has a lein-cloudbees plugin he was wanting some assist with ( not sure what exactly off hand tho ) |
| 16:29 | antares_ | technomancy: I have clj-time 0.3.1 and clojure.data.json 0.1.1 in my dev dependencies, running on Clojure 1.3.0 |
| 16:29 | talios | will sling him your email when I speak to him next tho |
| 16:30 | antares_ | technomancy: also, with lein 1.6.2-SNAPSHOT the issue disappears :/ |
| 16:30 | technomancy | antares_: dev-dependencies must work with the same version of clojure that leiningen uses |
| 16:30 | technomancy | so libraries that require 1.3 are right out |
| 16:30 | cemerick | data.json is clean, so I'd suspect clj-time |
| 16:31 | talios | really? do you have a lein13 release at all? |
| 16:31 | technomancy | antares_: it shouldn't work with 1.6.2-SNAPSHOT either; that's quite strange |
| 16:31 | antares_ | technomancy: the stack trace suggest something is wrong in the leiningen.utils.paths$legacy_native_path which I cannot find on 1.6.x branch |
| 16:31 | talios | 'lo cemerick |
| 16:31 | technomancy | talios: I can't make a breaking change like that in the 1.x version series |
| 16:31 | cemerick | talios: :-) |
| 16:31 | talios | technomancy: fair enough. "but if its good enough for Rich..." :) |
| 16:32 | antares_ | technomancy: so dev dependencies cannot be used with 1.3.0, did I understand you correctly? will leiningen be 1.3.0-compatible any time soon? I see self-install still uses 1.2.1 |
| 16:32 | cemerick | talios: BTW, feel free to keep bashing netbeans :-P |
| 16:32 | technomancy | antares_: it's a long way out; maybe six months |
| 16:32 | talios | cemerick: willdo :) |
| 16:33 | antares_ | technomancy: so it (1.3.0-compatible version) is out already, correct? |
| 16:33 | technomancy | antares_: no, it won't be out for a long time |
| 16:33 | antares_ | hm, ok |
| 16:33 | antares_ | what are reasons for not being 1.3.0-compatible? |
| 16:34 | technomancy | antares_: it would break the majority of existing leiningen plugins |
| 16:34 | technomancy | rather than waiting it'd be much better to just add backwards-compatibility to the libraries you are considering that currently require 1.3.0 |
| 16:34 | antares_ | ok, I see |
| 16:42 | tolstoy | I have core.clj, and a util.clj, and I want to use util.clj as in util/foo. But (:use my-app.util :as util) isn't working. What am I missing? |
| 16:43 | tolstoy | Oh, wait. Different part of my code is breaking. |
| 16:43 | cemerick | tolstoy: In any case, it's: (:use [my-all.util :as util]) |
| 16:44 | hiredman | http://groups.google.com/group/clojure/browse_thread/thread/59f0ef691311fad5?hl=en is like some kind of dark sad comedy of errors |
| 16:44 | hiredman | ns is really rather terrible |
| 16:46 | tolstoy | Now I get a class not found error. Oy! |
| 16:46 | hiredman | tolstoy: you want require :as |
| 16:48 | tolstoy | Hm. Still not working. Is there a good project I can look at with an example? |
| 16:49 | hiredman | what error? |
| 16:50 | bhenry | i need help using a java method on an object with clojure. https://gist.github.com/1296675 |
| 16:50 | hiredman | it's a static method |
| 16:50 | bhenry | hiredman, does that mean it's unusable? or that there is a different way to use it? |
| 16:50 | hiredman | ~google clojure java static methods |
| 16:51 | clojurebot | First, out of 7540 results is: |
| 16:51 | clojurebot | Java Interop - Clojure |
| 16:51 | clojurebot | http://clojure.org/java_interop |
| 16:52 | tolstoy | Ah! Parenthesis problem. Phew. |
| 16:52 | dnolen | bhenry: ns is not particularly newbie friendly, and use, require fns complicate the issue. |
| 16:53 | spoon16 | ,(Class/forName "mystringhere") |
| 16:53 | clojurebot | #<RuntimeException java.lang.RuntimeException: java.lang.ClassNotFoundException: mystringhere> |
| 16:53 | spoon16 | bhenry: is that what you were looking for? |
| 16:54 | bhenry | spoon16: no it was (. Class forName "mystringhere") |
| 16:54 | bhenry | instead of (.forName Class "mystringhere") |
| 16:54 | jcromartie | bhenry: did you check that page? |
| 16:54 | hiredman | ,(macroexpand `(Class/forName "foo")) |
| 16:54 | clojurebot | (. java.lang.Class forName "foo") |
| 16:54 | jcromartie | http://clojure.org/java_interop says (Classname/staticMethod args*) |
| 16:55 | bhenry | i saw a different part of the page... |
| 16:55 | jcromartie | (excellent illustration, hiredman) |
| 16:56 | spoon16 | jcromartie: do we need parens around english now? ;) |
| 16:57 | jcromartie | (assoc (:illustration hiredman) :excellent true) |
| 16:59 | amalloy | jcromartie: laaaame. you want an update-in |
| 16:59 | amalloy | or assoc-in is enough here, i guess |
| 16:59 | bhenry | it could be assoc if he made a map instead |
| 17:00 | jcromartie | amalloy: true :P |
| 17:02 | jcromartie | off-topic: my friend insists that Java is complicated and obfucsated |
| 17:02 | spoon16 | ,(assoc { :illustration hiredman } :excellent true) |
| 17:02 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: hiredman in this context, compiling:(NO_SOURCE_PATH:0)> |
| 17:03 | spoon16 | what is he comparing it to? |
| 17:03 | jcromartie | compared to C# |
| 17:03 | jcromartie | or Perl |
| 17:03 | jcromartie | and he's not trolling |
| 17:03 | spoon16 | I agree (vs C#) |
| 17:03 | amalloy | nor is he really wrong? i'm an old java dev, but c# is cleaner |
| 17:04 | jcromartie | spoon16: C# lets you write simpler code than Java, but C# is not a simpler language |
| 17:04 | jcromartie | well, more concise code |
| 17:05 | brehaut | depends if xml counts as java code :P |
| 17:05 | spoon16 | jcromartie: you are right, but one benefit of the MSFT ecosystem is that a significant portion of what you use while building a useful application is delivered by MSFT (with great documentation and consistency) that makes it super easy to open VS and build something. The languages are comparable but the effort to organize all the libs you need to build something useful with Java is significantly more complicated than if you were to use C#. IMO |
| 17:06 | jcromartie | spoon16: but at the same time, the JVM is a much simpler platform |
| 17:06 | bhenry | i can't get clojure to connect to an AdvantageDatabaseServer. if someone knows how to do this, please help me. |
| 17:06 | jcromartie | the classpath is so simple compared to .NET's various GACs and whatnot |
| 17:06 | spoon16 | I'm not a C# champion, I don't use it anymore for work… but I did use it for 5 years and I miss some things about how unified the experience was |
| 17:06 | jcromartie | yes :) |
| 17:08 | jcromartie | and compare Clojure language version management to something like RVM |
| 17:08 | jcromartie | having the whole language and your project's dependencies bundled up in a lib/ directory is great |
| 17:08 | jcromartie | and as far as I know, the JVM is the easiest place to do that |
| 17:09 | amalloy | i don't know what a GAC is but the classpath is a huge source of error for projects |
| 17:09 | brehaut | Global Assembly Cache: its where jit'd assemblies of clr code live in .net |
| 17:10 | jcromartie | amalloy: the Global Assembly Cache... you have to muck around with registering libraries and things are hidden behind user-friendly fake folders, etc. |
| 17:10 | amalloy | jcromartie: you're talking about the jvm ecosystem here, not java. java projects don't get their whole language in a library |
| 17:10 | jcromartie | right |
| 17:10 | jcromartie | yes, I think I can say the JVM ecosystem is pretty simple |
| 17:11 | jcromartie | at least, the JVM is like a 5-speed manual transmission, and the CLR is like an electronically-controlled dual-clutch multiple-shaft DSG |
| 17:12 | jcromartie | sure, you can get it wrong in the JVM |
| 17:12 | jcromartie | but not as spectacularly wrong as it can get in the CLR |
| 17:12 | jcromartie | like, pulling your hair out trying to solve some assembly version conflict in a machine's hidden global library cache :) |
| 17:13 | jcromartie | classpath problems are solved by looking at your classpath and fixing it |
| 17:13 | jcromartie | easy |
| 17:14 | jrabbit | is there a way to make slurp and text tools not barf on large files? |
| 17:14 | jrabbit | it loads it all into memory and then the jvm breaks with an OOM error |
| 17:15 | hiredman | don't use slurp |
| 17:15 | jrabbit | whats the better tool :) |
| 17:17 | jcromartie | jrabbit: it depends on what you are reading |
| 17:18 | jcromartie | but basically you want to use a BufferedReader |
| 17:18 | jcromartie | (or am I way off here...?) |
| 17:18 | jrabbit | i think so |
| 17:19 | jrabbit | its ~50mb of irc logs they're just being read inefficently |
| 17:19 | jcromartie | actually, BufferedReader is what you want |
| 17:19 | jrabbit | clojure.java.io/reader seems good too |
| 17:19 | jcromartie | which returns a BufferedReader :) |
| 17:20 | ibdknox | why are we talking about the GAC? |
| 17:20 | jrabbit | is there a reason to ah. |
| 17:20 | jcromartie | (line-seq (clojure.java.io/reader "your/irc.logs")) |
| 17:20 | jrabbit | heh |
| 17:20 | jcromartie | ibdknox: arguing wether Java/JVM is simple compared to CLR |
| 17:20 | jrabbit | I guess I can try and rewrite my filter/map stuff |
| 17:20 | amalloy | jcromartie: not very good resource management there - you never close the reader |
| 17:20 | ibdknox | hrm |
| 17:21 | ibdknox | jcromartie, either can be equally complex I would say |
| 17:21 | jcromartie | hah, sorry amalloy... I thought line-seq closed the reader |
| 17:21 | jcromartie | er, sorry jrabbit |
| 17:22 | jrabbit | hmm |
| 17:23 | jrabbit | amalloy: what does close it? :P |
| 17:23 | jcromartie | (.close rdr) |
| 17:23 | amalloy | &(doc with-open) |
| 17:23 | lazybot | ⇒ "Macro ([bindings & body]); bindings => [name init ...] Evaluates body in a try expression with names bound to the values of the inits, and a finally clause that calls (.close name) on each name in reverse order." |
| 17:23 | jcromartie | oh that's handy :) |
| 17:24 | jrabbit | thats writen so opaquely >_> |
| 17:25 | jrabbit | I understand what it is because I've been looking at other functions but urgh if I was looking for it.. |
| 17:25 | jcromartie | clojure docs mince no words |
| 17:26 | ibdknox | Clojure docs need some love. |
| 17:26 | technomancy | that one's not so bad |
| 17:27 | technomancy | it's the ns docs that are inscrutable |
| 17:27 | ibdknox | ugh |
| 17:27 | jrabbit | (:require clojure.contrib.io)).. |
| 17:27 | jrabbit | #<CompilerException java.lang.Exception: Unable to resolve symbol: read-lines in this context (NO_SOURCE_FILE:15)> |
| 17:27 | jrabbit | Lovely. |
| 17:27 | ibdknox | jrabbit, use clojure.java.io |
| 17:27 | jrabbit | I was before... :\ |
| 17:27 | jrabbit | confusing |
| 17:28 | jcromartie | you can use :only |
| 17:28 | jcromartie | or require :as |
| 17:28 | jrabbit | http://richhickey.github.com/clojure-contrib/io-api.html#clojure.contrib.io/read-lines is there a useful similar function? |
| 17:28 | lazybot | Nooooo, that's so out of date! Please see instead http://clojure.github.com/clojure-contrib/io-api.html#clojure.contrib.io/read-lines and try to stop linking to rich's repo. |
| 17:28 | jcromartie | oh wait, read-lines |
| 17:28 | technomancy | heh; that's ironic |
| 17:28 | jrabbit | oh the link isn't 1.3 :D |
| 17:29 | technomancy | "Please see this slightly less out-of-date link instead" |
| 17:29 | ibdknox | amalloy, stop misleading people ^^ |
| 17:29 | jrabbit | why isn't htere a clojure.java.io doc then? |
| 17:29 | ibdknox | or Raynes, whichever one of you wrote that one |
| 17:29 | jrabbit | well atleast I'm doing this now and not with something important |
| 17:30 | amalloy | technomancy: yeah, alas. it just swaps rich's repo for the canonical one; it doesn't know anything about contrib |
| 17:30 | Raynes | ibdknox: I had nothing to do with that. |
| 17:30 | technomancy | jrabbit: http://copperthoughts.com/p/clojure-io-p1/ is the best documentatino I've found on c.j.io |
| 17:33 | jrabbit | ooh it worked |
| 17:33 | jrabbit | line-seq is exactly what I want lets see if it works |
| 17:33 | jrabbit | oh clojure you lazily defined that |
| 17:34 | jrabbit | woo it works without crashing the jvm. lovely. |
| 17:35 | jrabbit | technomancy: ibdknox thanks |
| 17:35 | jrabbit | jcromartie: you too |
| 17:35 | spoon16 | I have a let variable that i would like to replace with a different reference |
| 17:35 | spoon16 | ,(let [im {}] (map-indexed #(let [i %1 p %2] (assoc im p i)) [:x :y :z]) im) |
| 17:35 | clojurebot | {} |
| 17:35 | spoon16 | I know that is not how let works |
| 17:35 | spoon16 | but what would be the right solution? |
| 17:36 | spoon16 | how can I append the result of (assoc) to im |
| 17:36 | amalloy | reduce |
| 17:42 | Raynes | technomancy: If you were going to write a library to interface with a bunch of url shorteners, what would you name it? |
| 17:42 | jcromartie | shortyplexer |
| 17:42 | jcromartie | oh wait |
| 17:43 | jcromartie | question was not for me :) |
| 17:43 | amalloy | Raynes: he'd name it after a literary midget |
| 17:44 | ibdknox | lol |
| 17:44 | Raynes | amalloy: I figured as much. |
| 17:44 | technoma- | I was just thinking that "zeugma" would be a great project name |
| 17:44 | technoma- | but you might want to save it for something involving polymorphism |
| 17:45 | ibdknox | for anyone else who didn't know: http://en.wikipedia.org/wiki/Zeugma |
| 17:45 | ibdknox | :) |
| 17:46 | Raynes | I should name it ibdknox |
| 17:46 | ibdknox | lol |
| 17:46 | ibdknox | I am relatively short I guess |
| 17:46 | brehaut | does the company of dwarves in the hobbit have a name? |
| 17:47 | Raynes | I'd hate to give the impression that I've already read The Hobbit. |
| 17:47 | technomancy | wow, I didn't know there were that many kinds of zeugmas |
| 17:47 | Raynes | It's bad enough that I named my weather library Ororo, implying that I even remotely care about xmen. |
| 17:47 | technomancy | I had always taken it to just mean a syllepsis |
| 17:47 | ibdknox | haha |
| 17:47 | technomancy | "time flies like an arrow; fruit flies like a banana" |
| 17:47 | technomancy | etc |
| 17:48 | Raynes | That said, I do have experience with The Lord of the Rings, and thus 'hobbit' is a possible name. |
| 17:48 | Raynes | Since they're awfully short. |
| 18:02 | tolstoy | url-shrtnr |
| 18:03 | tolstoy | url.shrtnr |
| 18:08 | amalloy | huh. i was surprised to find that (let [f (fn ...)] (def foo f)) doesn't behave quite the same as (def foo (fn ...)) |
| 18:11 | dnolen | amalloy: what's different |
| 18:11 | amalloy | dnolen: classname of generated function |
| 18:12 | amalloy | in the former case it's core$eval23421$fn_23422, and in the latter it's core$foo |
| 18:12 | amalloy | it looks like the compiler has special logic when it parses def, explicitly checking to see if the value is a function expression, and telling it to use a different name if so |
| 18:13 | dnolen | ibdknox: giving a lightning talk tomorrow on ClojureScript, anything you think I should point out as being particularly cool? |
| 18:14 | amalloy | i guess i thought that defn got the function to have a nice name because it uses (fn foo ...), but it turns out that just changes the fn__ to foo__, not replace the whole name |
| 18:16 | amalloy | and apparently if you wrap the def in a let, you no longer get a pretty name |
| 18:17 | amalloy | (let [] (defn foo [])) ;; core$eval12548$foo__12549 |
| 18:17 | ibdknox | dnolen, the idea of transparent client/server interaction is pretty neat |
| 18:17 | dnolen | yup, will definitely mention that. |
| 18:18 | ibdknox | dnolen, pinot remotes serve as an example if you need one |
| 18:18 | ibdknox | dnolen, macros and repl are the only other "wow" things I can think of |
| 18:18 | dnolen | ibdknox: I still need to give the pinot/noir pairing a try. Noone's done a blog post or video of that right? |
| 18:19 | duck1123 | pinot works without noir, right? |
| 18:19 | ibdknox | it does |
| 18:19 | ibdknox | dnolen, nope, I haven't been focusing a ton on that yet |
| 18:19 | dnolen | ibdknox: yeah, I think the rest of the wow stuff comes after much larger investment of time ... |
| 18:20 | ibdknox | dnolen, either at the conj or shortly thereafter I should have some cool stuff for folks |
| 18:20 | ibdknox | in terms of pinot |
| 18:20 | brehaut | cljs has non-shitty collections right? |
| 18:20 | ibdknox | brehaut, yep |
| 18:21 | brehaut | thats marquee bloody feature for the browser right there |
| 18:21 | dnolen | brehaut: haha, true I mention that. |
| 18:22 | brehaut | not that im bitter about javascript completely crap collections |
| 18:22 | amalloy | huh. slime has slime-macroexpand-all-inplace. why would you ever want that? "replace my macro-using source code the expanded version"? |
| 18:23 | dnolen | amalloy: that pretty useful when debugging macros, I often copy and paste crap around when doing serious debugging. |
| 18:23 | amalloy | dnolen: slime-macroexpand-all is useful, but not inplace surely |
| 18:24 | dnolen | amalloy: I don't think you can run C-x C-e in the macroexpand buffer right? (maybe totally wrong here). but often you want to expand inside some other form w/ locals or something. |
| 18:25 | amalloy | i think i see what you mean. C-x C-e does work in the macroexpand buffer, but i can imagine there being something that doesn't |
| 18:29 | duck1123 | with git, it's not that bad |
| 18:45 | crazyFox | hi. i am proxying a JPanel and I would like to add it as a ComponentListener of itself. I am doing this in a doto form (http://pastebin.com/YWsgJPAK). I figured I should use the Java 'this' reference - which the compiler doesnt like. Suggestions? |
| 18:47 | amalloy | ...really, pastebin? you want me to enter a captcha to *read* crazyFox's paste? |
| 18:47 | crazyFox | ^^ didnt know - wait... |
| 18:47 | ibdknox | same here |
| 18:48 | sritchie | hey all -- I'm migrating over to 1.3, and am running into this error: java.lang.NoSuchMethodError: clojure.lang.Numbers.lt(II)Z |
| 18:48 | amalloy | crazyFox: `this` doesn't mean anything special in clojure |
| 18:48 | sritchie | it's on a line with a doseq |
| 18:48 | crazyFox | re: captcha: try now |
| 18:49 | amalloy | sritchie: Raynes had that issue the other day - maybe he figured out what was going on |
| 18:49 | Raynes | Yes, I did. And then I forgot... |
| 18:49 | sritchie | haha, oh no |
| 18:49 | Raynes | sritchie: Could you show me your project.clj file? |
| 18:49 | Raynes | Might ring a bell or two. |
| 18:49 | amalloy | crazyFox: if you want to use the "implicit" value of a doto twice, you're mostly out of luck and need to do the let yourself |
| 18:49 | ibdknox | sritchie, when was the last time you did lein clean? |
| 18:50 | ibdknox | sritchie, or the cake equivalent |
| 18:50 | sritchie | I've been cleaning away each time I try this |
| 18:50 | sritchie | let me paste the function that's causing the error function |
| 18:50 | sritchie | s/error function/error |
| 18:50 | lazybot | <sritchie> let me paste the function that's causing the error |
| 18:51 | technomancy_ | for what it's worth, lein clean in most cases is the equivalent of taking out the cartridge and blowing on it in an NES. |
| 18:51 | amalloy | crazyFox: (let [p (proxy ...)] (doto p (.setPreferredSize ...) (.addComponentListener p))) |
| 18:51 | ibdknox | technomancy_, that totally worked for me... |
| 18:51 | crazyFox | amalloy: ah! i was just typing sth like that to you - thx ill try it |
| 18:51 | sritchie | Raynes: https://gist.github.com/1296982 |
| 18:51 | technomancy_ | ibdknox: it's all psychological |
| 18:51 | sritchie | one of the classes defined in line 33 tosses this error |
| 18:52 | ibdknox | technomancy, I'll just stay over here, happy with my placebos :p |
| 18:52 | technomancy | placebos are way underrated |
| 18:52 | Raynes | I can't believe that I can't remember what was causing that error... |
| 18:52 | ibdknox | technomancy, actually there have been a few times when lein clean did exactly what I needed it to |
| 18:52 | amalloy | sritchie: fwiw, (list* a b c) == (cons a (cons b c)) |
| 18:53 | technomancy | ibdknox: the only time I can think of is when you change dependencies |
| 18:53 | technomancy | ibdknox: is there something else? |
| 18:53 | sritchie | dnolen: yeah, I've been nuking the dirs in ~/.m2 as well |
| 18:53 | dnolen | Clojure Voodoo Practices 2nd Ed |
| 18:53 | ibdknox | technomancy, nope, it was always when I switched versions of things |
| 18:53 | technomancy | ibdknox: thanks for reminding me though; I need to make deps run an implicit clean =) |
| 18:54 | ibdknox | technomancy, :) |
| 18:56 | sritchie | Raynes: false alarm, I think lein clean fixed me up |
| 18:56 | ibdknox | HAH |
| 18:56 | sritchie | :) |
| 18:56 | ibdknox | told you. |
| 18:56 | technomancy | what |
| 18:56 | sritchie | it's the cure-all! |
| 18:56 | sritchie | I'm going to robert hooke lein clean onto everything |
| 18:56 | ibdknox | I remember that error too, and it had something to do with a .class file hanging around that was compiled with some older version of a dep |
| 18:57 | technomancy | ok, implementing it now |
| 18:57 | sritchie | ibdknox: loving noir, by the way |
| 18:57 | ibdknox | sritchie, sweet :) |
| 18:57 | sritchie | I'm working on a webapp now using noir and enlive |
| 18:57 | ibdknox | and it's going well? |
| 18:57 | cemerick | sritchie: fold a call to rm -rf ~/.m2/repository too — repeatable builds FTW :-P |
| 18:58 | sritchie | yup, very well, I had started working in rails some time ago, and jumped ship completely for noir |
| 18:58 | sritchie | I'll write up a post soon on some of the code I've been writing for forms, etc |
| 18:59 | technomancy | ibdknox: is noir going to have authentication built-in, or is that best delegated to something like sandbar? |
| 18:59 | technomancy | it looks like you provide some of the building blocks for auth/login, but there's still a fair amount to stitch together |
| 19:00 | technomancy | maybe that's intentional due to no one-size-fits-all? |
| 19:00 | ibdknox | technomancy, yeah, I don't think there is a truly general solution that works |
| 19:00 | ibdknox | technomancy, one thing I hope to see moving forward are a set of small components built on noir for common things like that though |
| 19:01 | ibdknox | technomancy, for example, most auth libs assume you're using a SQL database... for many projects I do now, I don't have one |
| 19:01 | technomancy | yeah, you need a pluggable storage mechanism of some type |
| 19:01 | cemerick | building a Clojure wrapper around spring-security is item #86 on my TODO list |
| 19:01 | ibdknox | technomancy, it's on my todo list |
| 19:01 | technomancy | I assume you're refering to sandbar? |
| 19:01 | technomancy | cemerick: can you tame the beast? |
| 19:02 | technomancy | I've never used spring, but from what I've heard it sounds a bit scary. |
| 19:02 | cemerick | spring is scary |
| 19:02 | ibdknox | very, very scary |
| 19:02 | cemerick | spring-security is derived from a framework that was folded into spring proper long after it matured |
| 19:02 | cemerick | it's just a ton of authentication/authorization mechanisms + a servlet filter |
| 19:03 | amalloy | clojurebot: spring is scary. very, very scary |
| 19:03 | clojurebot | You don't have to tell me twice. |
| 19:05 | ibdknox | technomancy, I should point out, that writing authentication specific to you app should be really lightweight... If you find that's not true, you should let me know |
| 19:05 | ibdknox | your* |
| 19:05 | ibdknox | technomancy, pre-routes should do most of the work for you |
| 19:06 | ibdknox | technomancy, or do you mean the user storage aspects? |
| 19:06 | sritchie | authentication with noir alone was fine; |
| 19:06 | sritchie | I ended up using sandbar for validations |
| 19:07 | chewbranca | /msg technomancy weird emacs got pegged at 100% cpu and locked up |
| 19:07 | chewbranca | on me until I smashed C-C on the keyboard lol |
| 19:07 | ibdknox | sritchie, what was missing? Or did you just like the form generation stuff? |
| 19:08 | technomancy | ibdknox: I haven't gotten to it yet... been putting it off =) |
| 19:08 | technomancy | but you're probably right |
| 19:08 | sritchie | ibdknox: let me take a look at my code to see what I ended up doing, one sec |
| 19:10 | ibdknox | I have a general aversion to things that generate HTML structure for me, since it's very rare that the generated HTML would hold up to the requirements of the design |
| 19:11 | technomancy | what pisses me off is that browsers still don't offer a way to style HTTP basic auth |
| 19:11 | ibdknox | haha |
| 19:11 | ibdknox | and probably never will |
| 19:11 | sritchie | ibdknox: I don't know that the noir validators wouldn't do this for me, but I liked the way sandbar allows for composition of validators |
| 19:11 | sritchie | https://gist.github.com/1297027 |
| 19:11 | technomancy | it's 2011 or whatever year it happens to be and we are still coding HTML forms to perform login; wtf. |
| 19:12 | sritchie | ibdknox: I ended up with a defform macro that generates the form and a corresponding defpage, to accept the action; https://gist.github.com/1297033 |
| 19:13 | ibdknox | sritchie, cool :) |
| 19:14 | sritchie | it redirects back to the sending action on failure, using noir's method of registering errors |
| 19:16 | ibdknox | technomancy, you could steal most of the work from the noir-blog example |
| 19:17 | technomancy | ibdknox: thanks for the tip |
| 19:18 | tolstoy | If you have a defrecord inside a namespace for use only inside that namespace, is there a way to make it private (like defn- type of thing)? |
| 19:18 | ibdknox | tolstoy, why do you want to? |
| 19:18 | tolstoy | It's only meant to be useful inside that namespace. |
| 19:19 | pandeiro | how are people including their clojurescript dependencies? just manually copying over? is it a bad idea to stick my libs into $CLOJURESCRIPT_HOME so I can always find them if I need to automate project creation? |
| 19:19 | tolstoy | If nothing else, marking it "hidden" would indicate that to readers. |
| 19:19 | ibdknox | you can set :private true in the metadata |
| 19:19 | ibdknox | I'm not actually sure what the implications of that are though |
| 19:20 | ibdknox | pandeiro, I jar pinot |
| 19:20 | ibdknox | pandeiro, and stick it on clojars |
| 19:20 | tolstoy | I'll give it a try and see what happens. Thanks! I couldn't remember what that particular metadata tag was (and can't find any associated docs). |
| 19:21 | pandeiro | ibdknox: that would mean you use lein for cljs projects too? just for the dep mgmt? |
| 19:21 | ibdknox | pandeiro, more or less. Though all of my projects also have a server for them :) |
| 19:22 | ibdknox | pandeiro, what you suggested is fine too though. I actually drop macros into my CLOJURESCRIPT_HOME/lib folder all the time |
| 19:22 | pandeiro | ibdknox: i see, cool... since i'm not using a clojure backend i think that works better for my flow |
| 19:22 | technomancy | ibdknox, sritchie: https://github.com/technomancy/leiningen/commit/13fb2bd80f1ef64a01cb383263e470bdc12470ea |
| 19:23 | ibdknox | wooohoo :) |
| 19:23 | sritchie | nice! |
| 19:23 | amalloy | tolstoy, ibdknox: marking a record as :private has no effect |
| 19:23 | ibdknox | amalloy, well it seems he wants to do it more as a marker than anything |
| 19:24 | ibdknox | amalloy, what does *it* work on though? |
| 19:24 | amalloy | ibdknox: helpfully, you can read my comment either as "don't waste your time, it does nothing" or "it does nothing, so knock yourself out" |
| 19:24 | amalloy | ibdknox: i don't understand the question? it works on vars |
| 19:25 | ibdknox | err rather, what does it do? Will it then except if I try to use it elsewhere? |
| 19:25 | spoon16 | best way to get last item in a vector? |
| 19:25 | amalloy | &(doc peek) |
| 19:25 | lazybot | ⇒ "([coll]); For a list or queue, same as first, for a vector, same as, but much more efficient than, last. If the collection is empty, returns nil." |
| 19:25 | spoon16 | peek |
| 19:25 | amalloy | ibdknox: on a var, or a record? |
| 19:25 | ibdknox | on a var |
| 19:26 | amalloy | it doesn't get referred in use/refer clauses |
| 19:26 | ibdknox | ah |
| 19:26 | amalloy | and i think there's no entry into your symbol table for require, either, now that i think of it |
| 19:26 | amalloy | you can still reach in and grab it by its varname |
| 19:26 | tolstoy | amalloy, ibdknox: I can't seem to get at the defrecord outside its namespace anyway, so….. |
| 19:26 | amalloy | tolstoy: that's because you're trying to use/require instead of import |
| 19:27 | tolstoy | amalloy: Ah, okay. defrecord gens a class, so you have to use import? |
| 19:27 | amalloy | yeah |
| 19:28 | tolstoy | Okay. I think I'm just not going to worry about it. I mean, what am I doing, OO? ;) |
| 19:29 | tolstoy | I get the impression that defrecord (new to me since my last clojure dabble) is a bit excessive as a local data structure. A map would work just as well. |
| 19:29 | ibdknox | tolstoy, correct |
| 19:30 | ibdknox | In my experience records are rarely the "right" solution |
| 19:30 | tolstoy | Better used as (sort of) value objects transmitted from layer to layer in an app? |
| 19:30 | tolstoy | For instance, a web request takes form data, stuffs it in a defrecord, hands it off to a persistence layer? That type of thing? |
| 19:31 | ibdknox | maps work wonderfully for that |
| 19:32 | tolstoy | What's the use case for defrecord, then? Java interop? |
| 19:32 | amalloy | tolstoy: java interop, protocol implementations, and high-performance special-case-only maps |
| 19:33 | amalloy | and they're not that useful for java interop a lot of the time |
| 19:34 | ibdknox | using them with protocols is the interesting case |
| 19:34 | todun | is there a way/test to determine if a seq or collection has nested seqs or collection? |
| 19:34 | ibdknox | ,(doc some) |
| 19:34 | clojurebot | "([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)" |
| 19:34 | ibdknox | ,(some coll? [1 2 3]) |
| 19:34 | clojurebot | nil |
| 19:35 | ibdknox | ,(some coll? [[] 1 2]) |
| 19:35 | clojurebot | true |
| 19:35 | ibdknox | todun, ^ |
| 19:35 | todun | ,^ |
| 19:35 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading> |
| 19:36 | todun | ibdknox: how do I use that command? |
| 19:37 | ibdknox | todun, I was pointing up |
| 19:37 | todun | ,(^ '(1 2 '(1 2))) |
| 19:37 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Metadata must be Symbol,Keyword,String or Map> |
| 19:37 | ibdknox | todun, the answer was some |
| 19:37 | todun | ibdknox: oh. oops. sorry. thanks. |
| 19:48 | jodaro | i seem to be falling into a trap of having a bunch of stuff in a let |
| 19:48 | jodaro | and then like hardly anything in the rest of the function |
| 19:48 | ibdknox | chances are you should have multiple functions |
| 19:49 | ibdknox | to clean out the let a bit, if it's getting really long |
| 19:49 | jodaro | yeah |
| 19:49 | jodaro | i'll split this up |
| 19:54 | amalloy | i don't think there's anything wrong with having most of your function body in a let-binding |
| 19:57 | jodaro | i'm new enough that i can't decide if its right or not |
| 19:57 | jodaro | there is no doubt that this function can/should be split up a bit, though |
| 19:59 | dnolen | I think the thing to watch out for is this, http://stackoverflow.com/questions/7812635/how-do-i-effectively-manage-a-clojure-code-base |
| 19:59 | dnolen | it's easy to get carried away and make lots of small fns - even if they're interdependent |
| 20:00 | dnolen | if you can't put something and get something sensible out w/o involving a lot of other stuff, it might be doing too little. |
| 20:00 | dnolen | I'm a fan of letfn. |
| 20:02 | jodaro | this particular function is part of a rest/web api client |
| 20:03 | jodaro | for simplicity |
| 20:03 | jodaro | the first round took all the args |
| 20:03 | jodaro | did some processing on them (with the help of a separate function for one thing, at least) |
| 20:03 | jodaro | prepped the request |
| 20:03 | jodaro | executed the request |
| 20:03 | jodaro | and parsed the response |
| 20:03 | jodaro | so its too much for one function for sure |
| 20:04 | jodaro | i think it would be reasonable to go with a prepare, an execute, and a parse |
| 20:30 | tolstoy | If I want to "subclass" an exception (say) so I can store some state in it for when the exception gets thrown, can I use "reify"? Should I use proxy? |
| 20:31 | tolstoy | gen-and-load-class? |
| 20:35 | dnolen | tolstoy: Throwable has to be subclassed, you can't use reify (I think) |
| 20:35 | tolstoy | How do you subclass? |
| 20:36 | tolstoy | Looks like Proxy is it. |
| 20:40 | brehaut | tolstoy: http://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/ |
| 20:40 | technomancy | wait wait |
| 20:40 | technomancy | don't subclass exceptions |
| 20:40 | technomancy | clojurebot: slingshot? |
| 20:40 | clojurebot | slingshot is the successor to clojure.contrib.condition: https://github.com/scgilardi/slingshot |
| 20:41 | technomancy | ^ use that instead |
| 20:48 | tolstoy | Ah, okay. |
| 20:48 | tolstoy | Really, I just need to store some stuff in a "thread" so that when the thread dies, I can reconstruct another one. |
| 20:49 | tolstoy | (All of which is much easier with actors and trap-exit.) |
| 20:49 | Zolrath | I've been refreshing infoq.com constantly over the past two days, I thought Rich's Strange Loop Talk and the Storm talk were supposed to go up yesterday |
| 20:54 | tolstoy | Ah, I can use a closure: (let [state (whtever |
| 20:55 | tolstoy | Ah, I can use a closure: (let [state (whtever)] (reify …….. use state.)) |
| 21:19 | trptcolin | my brain is melting: what could make @#'foo different from foo? (same thread; one line after the next; order doesn't matter) |
| 21:20 | todun | I'm looking for a list of clojure predicates. anyone know of any? thanks. |
| 21:21 | amalloy | &(and true false) |
| 21:21 | lazybot | ⇒ false |
| 21:21 | amalloy | &(@#'and true false) |
| 21:21 | lazybot | ⇒ true |
| 21:21 | amalloy | trptcolin: ^ |
| 21:21 | todun | sorry. I meant sequence predicates..like some |
| 21:22 | todun | I tried any but it didn't work and thus wondered if there was a list somewhere of these things. |
| 21:22 | todun | just read up the term thus my correcting my previous message late. |
| 21:22 | trptcolin | amalloy: bu-wha? why? |
| 21:22 | amalloy | trptcolin: it's my favorite parlor trick |
| 21:23 | amalloy | @#'foo throws away the metadata that says foo is a macro |
| 21:23 | amalloy | (because that's stored on the var, which you tossed) |
| 21:23 | trptcolin | todun: searching for ? here will give you some stuff: http://clojure.github.com/clojure/ |
| 21:23 | amalloy | so instead the underlying function gets called, which takes two extra ignored args... |
| 21:23 | todun | trptcolin: thanks. will check it out. |
| 21:24 | amalloy | it's easier to see if you extend it: ##(@#'and true false 'x 'y) |
| 21:24 | lazybot | ⇒ (clojure.core/let [and__3468__auto__ x] (if and__3468__auto__ (clojure.core/and y) and__3468__auto__)) |
| 21:24 | trptcolin | amalloy: craazy. ok, so metadata gets tossed when deref'ing a var. anything else come to mind? |
| 21:25 | amalloy | no, but another implication of the same fact |
| 21:25 | amalloy | you "get around" the :private metadata on vars |
| 21:25 | trptcolin | in particular, i get an Unbound when trying to eval the symbol, and the thing that we're trying to bind when deref'ing |
| 21:26 | trptcolin | more interestingly, it's a behavior difference in 1.3 from 1.2.1 |
| 21:27 | trptcolin | having a hard time trimming it down to a small repro case, unfortunately |
| 21:28 | amalloy | trptcolin: not my area, alas |
| 21:31 | trptcolin | bummer :) thanks for thinking about it! |
| 21:50 | todun | I'm writing two separate routines that use recursion. The first removes all the elements from from a collection and returns the structure: so '(1 2 '(1 2)) returns '( '() ). The second performs nested reversals. So [1 2 [ 3 4] ] returns [ [ 4 3] 2 1]. I think I'm making a mistake using recur & loop. But I'm not sure what is wrong: http://pastebin.com/GKznMTHR . Any help is appreciated. thanks. |
| 21:52 | brehaut | todun dont def inside a defn |
| 21:52 | brehaut | todun: if you want local functions use let or letfn |
| 21:52 | amalloy | yeah, every time you do that a kitten dies |
| 21:52 | todun | brehaut: is it un-idiomatic or just plain wrong to do so? |
| 21:53 | todun | brehaut: ok. let me quickly read up on that.. |
| 21:53 | amalloy | todun: it is wrong |
| 21:53 | amalloy | it makes your code no longer threadsafe or functional, and also way slower |
| 21:53 | todun | amalloy: sad. I shall endeavor to stop. |
| 21:54 | todun | amalloy: I see. multi-threading is my next interest so that will not be good. |
| 21:54 | clojurebot | Alles klar |
| 21:54 | amalloy | clojurebot: forget amalloy: I see. multi-threading |is| my next interest so that will not be good. |
| 21:54 | clojurebot | I forgot that amalloy: I see. multi-threading is my next interest so that will not be good. |
| 21:55 | brehaut | ((fn structure [s] (mapcat (fn [x] (if (coll? x) (conj (empty x) (structure x)) ()))) s)) [1 2 '(3 4)]) |
| 21:55 | brehaut | ,((fn structure [s] (mapcat (fn [x] (if (coll? x) (conj (empty x) (structure x)) ()))) s)) [1 2 '(3 4)]) |
| 21:55 | clojurebot | #<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: sandbox$eval27$structure> |
| 21:55 | todun | ? |
| 21:57 | amalloy | ,((fn structure [s] (mapcat (fn [x] (if (coll? x) (conj (empty x) (structure x)) ())) s)) [1 2 '(3 4)]) |
| 21:57 | clojurebot | (()) |
| 21:57 | brehaut | amalloy: thanks |
| 21:58 | brehaut | todun: structure returns the structure without the content |
| 21:58 | amalloy | ,((fn structure [s] (mapcat (fn [x] (if (coll? x) (conj (empty x) (structure x)) ())) s)) '[1 2 (3 4) (5 (6 7))]) |
| 21:58 | clojurebot | (() (())) |
| 21:58 | amalloy | brehaut: possibly a more-instructive sample input ^ |
| 21:58 | brehaut | aha yes |
| 21:59 | todun | amalloy: brehaut that does look way smaller than I had. |
| 21:59 | amalloy | fwiw i'm not sure the (empty x) does you much good here, and might in fact be wrong on some inputs |
| 21:59 | todun | allot of new functions here. so was my approach hopeless? |
| 21:59 | brehaut | amalloy: in hindsight i agree |
| 21:59 | todun | my use of recur-loop? |
| 22:00 | amalloy | todun: i don't think it's hopeless, but it's needlessly complicated and not actually any more performant - loop/recur means you avoid using stack, but you use more heap instead |
| 22:01 | amalloy | and certainly hard to debug because of the complication |
| 22:01 | brehaut | ,((fn nested-reverse [s] (map #(if (coll? %) (nested-reverse %) %) (reverse s))) [1 2 [3 4]]) |
| 22:01 | clojurebot | ((4 3) 2 1) |
| 22:01 | brehaut | thats your other function right |
| 22:01 | brehaut | ? |
| 22:01 | todun | amalloy: so if I changed everything to use letfn, will it work better? |
| 22:01 | todun | brehaut: yes it is. thanks. |
| 22:01 | amalloy | todun: hell if i know. i can't read your code at all; see above :P |
| 22:02 | brehaut | this is an example of 'know your standard library' :) |
| 22:02 | brehaut | (everyone on 4clj is kicking my arse due to my poor stdlib knowledge) |
| 22:02 | todun | brehaut: amalloy ha. ok. I will try to improve it. my loop/recur really is not good. |
| 22:03 | amalloy | brehaut: who needs the standard library when you have reduce |
| 22:03 | amalloy | and juxt |
| 22:03 | brehaut | amalloy: who needs reduce when you have point free |
| 22:04 | amalloy | my client was so offended by point-free it kicked me out of the room to protect my innocent ears |
| 22:04 | amalloy | eyes? it's never clear which you're using to "listen" to someone talk on irc |
| 22:06 | brehaut | i blame the haskell for all my bad clojure idioms |
| 22:06 | archaic | i have never had to use load-file once when would you ever use it? |
| 22:07 | brehaut | when you write clojure 3 years ago, or if you are splitting a NS across multiple files? |
| 22:08 | amalloy | sounds about right |
| 22:09 | brehaut | archaic: eg http://stackoverflow.com/questions/4690758/splitting-a-clojure-namespace-over-multiple-files |
| 22:28 | todun | is there like an in-range? sort of predicate in clojure? thanks. |
| 22:31 | brehaut | ,(let [x 10] [(< 0 x 10) (< 0 x 20) (< 10 x 20) (<= 0 x 10)]) |
| 22:31 | clojurebot | [false true false true] |
| 22:32 | todun | thanks. that is interesting. |
| 22:33 | brehaut | todun: be sure to read the doc strigns for < and friends; they probably dont mean what you think they mean |
| 22:33 | todun | brehaut: yes. I can see that now. so different. thanks. |
| 22:33 | archaic | don't even think of them as gte/lte, rather ascending/descending .. makes it somewhat easier |
| 22:34 | brehaut | archaic: exactly right |
| 22:34 | brehaut | ,(< 10) |
| 22:34 | clojurebot | true |
| 22:34 | todun | archaic: ok. uhm.. |
| 22:35 | todun | ,(10 <) |
| 22:35 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn> |
| 22:35 | todun | ,(> 10) |
| 22:35 | clojurebot | true |
| 22:35 | brehaut | from memory < is strictly increasing, <= is monotonically increasing |
| 22:36 | todun | but why does it work when it compares just a single element? |
| 22:36 | brehaut | because one item is a sequence where every value is strictly greater than the previous |
| 22:37 | brehaut | inductively its the n case, rather than the n+1 |
| 22:37 | brehaut | if you think about it as less than, then its going to be confusing. |
| 22:38 | todun | I'll have to somehow wrap my head about this one. pretty strange I say. |
| 22:38 | brehaut | also useful to know is that = and not= are not binary ops |
| 22:39 | brehaut | todun: start by discarding the name you knew < by and start calling it 'increasing series' |
| 22:40 | brehaut | put it another way, if you had (def increasing? (partial apply <)) in your program, and you called (increasing? [10]) ; => true, it wouldnt be surprising |
| 22:40 | todun | brehaut: uhm...ok. that certainly helps. |
| 22:41 | brehaut | todun: sorry, (defn increasing? [s] (apply < s)) for the non-point free definition |
| 22:41 | todun | non-profit free? |
| 22:41 | todun | oh yes, so the name can work out. |
| 22:42 | brehaut | im sorry, im a recovering haskell dabbler |
| 22:43 | todun | haha. if I can understand clojure, that might be my next stop. |
| 22:44 | todun | I know this is not the jedit room, but I was wondering if any users of jedit with clojure run into the situation whereby int turns into the integral sign. |
| 22:46 | amalloy | hah. emacs users more often have the problem that (fn ...) turns into a curly f |
| 22:47 | brehaut | makes for great copy and paste fun |
| 22:51 | todun | :) |
| 23:16 | ThreeCups | Is it possible to take an argument list and automagically turn it into a map? something like (defn [id name] ...) and inside the function have access to a map equivalent to {:id id :name name}? |
| 23:17 | amalloy | ThreeCups: i have a util that is close to that |
| 23:17 | ThreeCups | amalloy: cool. Is it a macro? |
| 23:18 | amalloy | https://github.com/flatland/useful/blob/develop/src/useful/map.clj#L8 |
| 23:18 | ThreeCups | having a look now. Thanks! |
| 23:20 | amalloy | so you'd have to write (let [the-map (keyed [id name])] ...), but you can wrap another macro around that, to do that as part of defn |
| 23:21 | ThreeCups | Great. I'm just learning Clojure/Lisp, so it's good just to look at other people's code and learn |
| 23:22 | amalloy | ThreeCups: you might enjoy looking at useful, then. it contains a lot of stuff that ninjudd and i have found common enough to shove into a library |
| 23:25 | ThreeCups | Okay, I'll have a look. Is it on github? |
| 23:26 | ThreeCups | Oh... it's what I'm looking at :) |
| 23:28 | archaic | is there an easier way to have a shared util library between my projects than hosting it on git/clojars? do I need to learn maven for that? |
| 23:30 | amalloy | archaic: hosting on clojars is super-easy |
| 23:31 | amalloy | that's not *technically* an answer to your question, i guess |
| 23:33 | archaic | might go with that then, seems like overkill tho :) |
| 23:35 | ThreeCups | Is there no way to do this locally? E.g. include a local jar in a build with leiningen? |
| 23:36 | talios | if its in your local maven repo then you should be able to just declare it as a dependency. i assume lein installs to the maven repo since it uses it underneath? ( i'd hope so ) |
| 23:36 | amalloy | lein can install to your local repo, but technomancy frowns on builds that only work on one machine |
| 23:37 | talios | true. with good reason actually. |
| 23:37 | amalloy | and if you've put in the effort to get something maven-deployable, it's only like ten extra seconds to put it on github instead |
| 23:37 | amalloy | er, clojars |
| 23:37 | talios | I was just thinking -NOT- installing to local woul be a good idea. |
| 23:38 | talios | github bad imho - git repos are NOT for binaries. that seems like the wrong solution to me |
| 23:40 | amalloy | talios: see my correction |
| 23:40 | talios | aha :) |
| 23:40 | tomoj | is the github maven trick really putting jars in a git repo? |
| 23:40 | amalloy | tomoj: is there a github maven trick? |
| 23:41 | talios | tomoj: if its the one I'm thinking of then yeh, abuses the github wiki space i -think- |
| 23:41 | talios | i could be wrong tho |
| 23:41 | tomoj | http://cemerick.com/2010/08/24/hosting-maven-repos-on-github/ |
| 23:41 | alandipert | cemerick's approach is a repo |
| 23:42 | tomoj | yeah |
| 23:42 | alandipert | i think i've seen it done with pages as well |
| 23:42 | tomoj | I never read past the title I think |
| 23:42 | talios | pages is just a git repo as well isn't it? |
| 23:43 | tomoj | hmm |
| 23:43 | tomoj | git will provide a zip that would work as a jar, wouldn't it? |
| 23:43 | tomoj | oh, can't control the paths though.. |
| 23:43 | brehaut | talios: its a branch of a repo with a magic name isnt it? |
| 23:43 | talios | that sounds right |
| 23:46 | brehaut | talios: your in auckland right? |
| 23:46 | talios | brehaut: yep. where abouts are you? |
| 23:46 | brehaut | s/bad grammer/correct grammer/ |
| 23:47 | brehaut | talios: the tron |
| 23:47 | talios | your name is familar, and for some reason I think we've met - maybe. or not. |
| 23:47 | brehaut | i dont think we've met |
| 23:47 | brehaut | possible the twitter |
| 23:47 | talios | true. I blur between the JUG, twitter, irc, the podcast etc. these days |
| 23:48 | brehaut | are their many clojure people in auckland? |
| 23:48 | talios | 3 in this office :) a few others. there was/is a lisp group here but its kinda idle, arbscht runs it |
| 23:49 | brehaut | nice :) |
| 23:49 | talios | altho I confess to not having touched clojure in a LONG time. not even the maven plugin :( time time - where are thou? |
| 23:50 | brehaut | i dont get to do as much clj as id like either |
| 23:51 | spoon16 | does clj support #! /usr/bin/clj …. for command line execution of clojure scripts? |
| 23:52 | amalloy | spoon16: technically, yes: #! is a comment, so you can do that |
| 23:52 | amalloy | but (a) a system-wide clj is not very popular, and (b) as i understand it there's a limit on the size of shebang lines which means you can't get all your classpath info in for anything non-trivial |
| 23:52 | amalloy | also (c) the jvm starts up really slowly :P |
| 23:54 | brehaut | you might be better off with a shell script that wraps #! … lein run |
| 23:54 | spoon16 | I've got a bunch of little algorithms that I have implemented in different languages |
| 23:54 | brehaut | or cljs + nodejs |
| 23:54 | spoon16 | and I like being able to just run them with an input argument from bash |
| 23:54 | spoon16 | but maybe that is not the best way to go with my clojure implementations |
| 23:54 | archaic | i was wondering about the jvm startup issue with scripting.. can't you do what cake does with a second jvm in the background to get around it? |
| 23:54 | amalloy | $google clojure jark |
| 23:54 | lazybot | [jark -] http://icylisper.in/jark/scripting.html |
| 23:57 | spoon16 | that seems like a big hammer for what I want |
| 23:57 | spoon16 | easy enough to just run the repl |