2011-10-17
| 03:02 | kiuma | hello, is there a clojure plugin for netbeans 7.0.1 ? |
| 03:03 | scottj | there's whatever's the latest on enclojure's website |
| 03:24 | Blkt | good morning everyone |
| 03:32 | depy | yo |
| 03:38 | Blkt | :D |
| 04:00 | khaliG | has anyone here used proguard to optimise their clojure app? |
| 06:40 | todun | I am trying to do unit=testing. I write all my test functions into one file that is in the test/sractch path in the clojure project I create. Then I call the test like so: (clojure.contrib.test-is/run-tests & namespaces). This is how I saw it done in an example. No compilation. No change of namespaces. I get the following exception: java.lang.ClassNotFoundException: clojure.contrib.test-is (NO_SOURCE_FILE:0). Am I doing something wrong, yes? |
| 07:13 | todun | Another question. I try to remove a specific character from an input string using the following function http://pastebin.com/F1FBrRsd . I get an exception when I try this is in the REPL (java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Character). Is there a way to ensure that I don't get this error or I re-cast the input or accepting input of the function? |
| 07:15 | todun | When I try to cast it by making the input a list '(input) or a vector [input] I get the following exception in either case: java.lang.ClassCastException: java.lang.Character cannot be cast to clojure.lang.IFn |
| 07:17 | cemerick | todun: clojure.test supersedes c.c.test-is in all cases |
| 07:17 | todun1 | I'm a bit confused as to how to use def. the docs talk about (def symbol init?). def is defined to be a general form a function. And yet when I try to use the notation of defn to define a function, I get "too many argument" errors and such. Am I missing something here? |
| 07:18 | todun | cemerick: is that the exact syntax I should put in? |
| 07:18 | cemerick | is what the exact syntax? |
| 07:19 | todun | cemerick: clojure.test supersedes c.c.test-is in all cases |
| 07:19 | cemerick | that's not syntax, that's a sentence :-) |
| 07:19 | todun | lol |
| 07:19 | todun | ok. |
| 07:20 | cemerick | It sounds like you could use a good Clojure book to help you along. There are many fine choices. |
| 07:20 | todun | cemerick: I'm reading two actively as I type. |
| 07:21 | cemerick | ah, ok |
| 07:21 | todun | do not know if they are the standard. But I welcome your suggestions. |
| 07:21 | todun | "Programming in Clojure" of which most just flies over my head, especially recursion which I'm trying to learn first. |
| 07:22 | todun | "Seven Languages in Seven Weeks" shorter intro lacks the necessary depth I need for problems that arise like the questions I've been asking. |
| 07:22 | cemerick | well, I'll help with your zg function; what are you trying to do exactly? |
| 07:23 | todun | remove certain characters from the string .eg. newline , tabs etc. |
| 07:24 | todun | I think I have the functionality down, but I don't know how to do the casting. perhaps I'm looking at the problem the wrong way. |
| 07:24 | cemerick | so `w` is a String? |
| 07:26 | todun | about to quickly change internet locations brb |
| 07:29 | todun | cemerick: yes. the input is a string |
| 07:31 | todun | cemerick: I tried making it a list or vector but I got a different exception as shown above. |
| 07:35 | cemerick | todun: there are many ways you can do this, but only one efficient way |
| 07:36 | todun | cemerick: ok... |
| 07:36 | todun | is my way right, wrong, efficient? |
| 07:37 | cemerick | OK, outside of benchmarking things, I retract that. :-) |
| 07:37 | cemerick | consider: |
| 07:37 | cemerick | ,(.replaceAll "hello\nthere" "\\n" "") |
| 07:37 | clojurebot | "hellothere" |
| 07:37 | cemerick | That's just using the replaceAll method on the java.lang.String class |
| 07:38 | cemerick | If you wanted to use sequences with remove, you would need to do: |
| 07:39 | cemerick | ,(apply str (remove #(= \newline %) "hello\nthere")) |
| 07:39 | clojurebot | "hellothere" |
| 07:39 | cemerick | todun: you were getting the error because `remove` is a function that takes a function as its first argument; you were passing a character |
| 07:40 | cemerick | (remove f sequence) is the equivalent of (filter (complement f) sequence), FWIW |
| 07:41 | todun | cemerick: ok. so I didn't even need to do filter all along |
| 07:41 | todun | I was repeating myself. |
| 07:41 | cemerick | well, you can filter if you want, but the result of that is a sequence, not a string |
| 07:41 | todun | , (defn zg [w] (filter (fn [w] (= w (not(char (range 32 126))))) (remove (char 10) w)) ) |
| 07:41 | clojurebot | #<Exception java.lang.Exception: SANBOX DENIED> |
| 07:42 | cemerick | ,(filter #(not= \newline %) "hello\nthere") |
| 07:42 | clojurebot | (\h \e \l \l \o ...) |
| 07:42 | todun | cemerick: what does % do in that? |
| 07:42 | gfredericks | cemerick: clojure ruins the example again :) |
| 07:42 | todun | is it like a wildcard? |
| 07:42 | cemerick | todun: you can't define var in the bot; only non-side-effecting expressions work. |
| 07:42 | gfredericks | s/clojure/clojurebot |
| 07:42 | lazybot | <gfredericks> cemerick: clojurebot ruins the example again :) |
| 07:43 | cemerick | todun: that's the short form of an anonymous fn. |
| 07:43 | todun | gfredericks: :) |
| 07:43 | todun | cemerick: ok. good to know. |
| 07:43 | cemerick | ,(filter (fn [char] (not= char \newline)) "hello\nthere") |
| 07:43 | clojurebot | (\h \e \l \l \o ...) |
| 07:43 | cemerick | to illustrate remove: |
| 07:43 | cemerick | ,(remove #(not= \newline %) "hello\nthere") |
| 07:43 | clojurebot | (\newline) |
| 07:44 | cemerick | ,(filter (complement #(not= \newline %)) "hello\nthere") |
| 07:44 | clojurebot | (\newline) |
| 07:45 | todun | cemerick: allot of new syntax. I'm testing as youshow. |
| 07:45 | todun | *you show |
| 07:46 | cemerick | I think I'm done with show and tell, back to work for me. :-) |
| 07:46 | cemerick | todun: There's lots of helpful people here, ask when you have questions/trouble. Make sure you keep reading, though. |
| 07:47 | todun | cemerick: thanks for clearly that up. |
| 07:47 | todun | cemerick: keep reading. always. but how can one escape the allure of coding first? |
| 07:47 | todun | *clearing |
| 07:47 | cemerick | Goes hand in hand, of course. :-) |
| 07:48 | todun | :) |
| 07:48 | archaic | hi just a quick question before I go digging is there an easy way to autodetect log files coming into a folder? |
| 07:50 | cemerick | archaic: In JDK 7, yes. Otherwise, no; polling, IIRC. |
| 07:54 | archaic | ahh java.nio.file? |
| 07:58 | cemerick | sounds right, yeah |
| 08:11 | fdaoud | good morning |
| 08:11 | fdaoud | I'm wondering why this doesn't work: |
| 08:12 | fdaoud | ,((first '(+ 1 1)) 38 4) |
| 08:12 | clojurebot | 4 |
| 08:12 | ljos | Hi - Where did import-static go? |
| 08:12 | ljos | in clojure 1.3 |
| 08:12 | fdaoud | can anyone help? How do I call + after getting a hold of it from a list? |
| 08:15 | ljos | fdaoud: I think you should be able to get it from the list and it should call, clojure being a lisp-1. |
| 08:16 | fdaoud | ljos: I think you're right, but how? |
| 08:16 | khaliG | you're getting back the symbol + not the function |
| 08:22 | gfredericks | fdaoud: you'd have to eval the symbol |
| 08:22 | gfredericks | i.e., ((eval (first '(+ 1 2))) 3 4) |
| 08:23 | fdaoud | ,((eval (first '(+ 1 2))) 3 4) |
| 08:23 | clojurebot | #<Exception java.lang.Exception: SANBOX DENIED> |
| 08:23 | gfredericks | fdaoud: and the bots don't let you do eval :) |
| 08:23 | gfredericks | it makes them skiddish |
| 08:24 | fdaoud | gfredericks: right :) well thanks.. but so is there a way without eval? 4clojure won't let you do eval either ;) |
| 08:24 | gfredericks | is this to actually solve a 4clojure problem or just some weird golfing thing you guys are always doing? |
| 08:24 | raek | fdaoud: ((first (list + 1 1)) 38 4) |
| 08:25 | khaliG | maybe you could implement scheme first? :P |
| 08:25 | fdaoud | ,((first (list + 1 1)) 38 4) |
| 08:25 | clojurebot | 42 |
| 08:25 | raek | now the first element in the list is not the symbol "+", but the function that "+" refers to |
| 08:26 | fdaoud | raek: is that different because in the first case, + is a symbol, and in the second case, it is the actual function? |
| 08:26 | raek | yes |
| 08:26 | gfredericks | at this point why don't we just simplify it to ##(+ 38 4)? Rather unclear constraints here |
| 08:26 | lazybot | ⇒ 42 |
| 08:26 | fdaoud | raek: right, you beat me to it :) |
| 08:26 | raek | 'list' is an ordinary function that evaluates its arguments |
| 08:26 | gfredericks | (def + (comp - (partial - 0))) |
| 08:27 | fdaoud | gfredericks: call it a learning experience :) |
| 08:27 | gfredericks | fdaoud: okay :) |
| 08:27 | fdaoud | thanks raek |
| 08:27 | raek | in my experience, quote is mostly used in macros in clojure |
| 08:27 | fdaoud | ,((first [+ 3 4]) 38 4) |
| 08:27 | clojurebot | 42 |
| 08:28 | fdaoud | makes sense now |
| 08:28 | raek | fdaoud: yeah, [..] instead of (list ..) is how you usually write collecions constants in code in clojure |
| 08:30 | fdaoud | raek: so say you are given '(+ 3 4) by a caller. How do you go from the symbol "+" to the function "+"? there is no other way than with eval? |
| 08:30 | gfredericks | fdaoud: that's a weird situation in the first place because + could mean different things in different namespaces |
| 08:30 | ljos | What is the easiest way to get public static variables into clojure from java? I'm getting a bit sic of this: (. Class var) . I was looking into import static, but I can't seem to find the package it is a part of in Clojure 1.3. |
| 08:30 | gfredericks | fdaoud: so it depends on what you want it to mean |
| 08:31 | raek | fdaoud: that is a very unusual situation, but yes either you have to use eval, or you have to write a function that interprets that data |
| 08:31 | kzar | I have the contents of file as a string, is there a way to make a java.io.File object or InputStream from it without saving it to disk as an actual file? |
| 08:31 | kzar | (Those are what clutch requires to add an attachment) |
| 08:31 | raek | fdaoud: if you want to delay the evaluation of a piece of code, wrap it in a (fn [] ...) instead |
| 08:31 | khaliG | fdaoud, i think in CL the symbol is a function designator so you can funcall it all the same. Not in Clojure though.. |
| 08:32 | raek | kzar: yes. use java.io.StringReader |
| 08:32 | fdaoud | I'm looking at http://www.4clojure.com/problem/121 |
| 08:32 | fdaoud | sorry I should have said that up front! |
| 08:33 | gfredericks | fdaoud: if you don't like eval and you have a small set of symbols you need to resolve you could create a map for it: {'+ +, '- -, ...} |
| 08:33 | raek | fdaoud: in that case, I think you should write a function that interprets the expression |
| 08:33 | fdaoud | gfredericks: it's 4clojure that doesn't like eval, not me |
| 08:33 | gfredericks | fdaoud: true :) |
| 08:35 | raek | kzar: if you need an InputStream, you can call (.getBytes the-string desired-encoding) and pass the result of that to the constructor of ByteArrayInputStream |
| 08:35 | fdaoud | gfredericks, raek: I think you're right, I'd have to write a function that interprets the expression, and actually map the symbols to the functions |
| 08:36 | fdaoud | I'll have a go at it.. thanks for your help! |
| 08:39 | kzar | raek: Gotya, thanks |
| 08:40 | fdaoud | ljos: I think (Class/var) works |
| 08:40 | fdaoud | ,(Math/PI) |
| 08:40 | clojurebot | 3.141592653589793 |
| 08:40 | raek | ,Math/PI |
| 08:40 | clojurebot | 3.141592653589793 |
| 08:41 | raek | for some reason, reading static fields and calling static methods have interchangable syntaxes |
| 08:41 | raek | but I prefer the notation without the parens for fields |
| 08:42 | fdaoud | right |
| 08:42 | fdaoud | I wouldn't use parens, my mistake |
| 08:42 | fdaoud | ,(* 2 Math/PI) |
| 08:42 | clojurebot | 6.283185307179586 |
| 08:44 | gfredericks | (def tau (* 2 Math/PI)) |
| 08:45 | ljos | fdaud: thank you. |
| 08:47 | jcromartie | ooh... |
| 08:47 | jcromartie | GZIPInputStream |
| 09:00 | ljos | hmmm.. I get an illegalArgumentException when I do Class/var. It says "no matching method". |
| 09:01 | ljos | hepp. probably somthing wrong on my end :) |
| 09:07 | bendlas | Hey, anybody else got troubles fetching [org.clojure/java.data "0.0.1-SNAPSHOT"] over maven? |
| 09:24 | micahmartin | I'm stumped on this one…. |
| 09:24 | micahmartin | How can I set metadata on a var inside a macro? |
| 09:25 | micahmartin | (declare ^:dynamic foo) works, but inside a macro the "^:dynamic" is stripped |
| 09:26 | micahmartin | … and the resulting var doesn't have the :dynamic metadata set |
| 09:27 | micahmartin | Any ideas? |
| 09:32 | duck1123 | there was a thread about this recently |
| 09:32 | duck1123 | you have to set the dynamic manually, |
| 09:33 | duck1123 | http://groups.google.com/group/clojure/browse_thread/thread/d5efd00c699f73a7/e59708f4c7b8e83f?hl=en&lnk=gst&q=dynamic#e59708f4c7b8e83f |
| 09:34 | duck1123 | this might be a slightly different issue |
| 09:50 | micahmartin | Good morning? |
| 09:50 | amcnamara | true |
| 09:57 | llasram | micahmartin: Are you sure that's the exact problem you're having? |
| 09:58 | llasram | ,(do (defmacro keep-meta [name] `(def ~name nil)) (keep-meta ^:dynamic example) (.isDynamic #'example)) |
| 09:58 | clojurebot | #<Exception java.lang.Exception: SANBOX DENIED> |
| 09:58 | llasram | Stupid bot |
| 09:58 | llasram | Anyway, I get get 'true' with 1.3 |
| 09:58 | gfredericks | yeah, stupid bot. |
| 09:58 | llasram | The metadata is attached to the symbol, which moves unmodified through the macro |
| 09:59 | llasram | If you're generating a new symbol, you need to copy the metadata manually using with-meta |
| 09:59 | llasram | gfredericks: Ok, I'm sure it's a very intelligent bot. :-) |
| 09:59 | gfredericks | :) |
| 10:00 | gfredericks | are the bots intelligent??? |
| 10:00 | lazybot | gfredericks: Yes, 100% for sure. |
| 10:01 | llasram | haha. awesome |
| 10:01 | micahmartin | llasram: Maybe I can take that approach and add the metadata to the symbol first. |
| 10:02 | llasram | micahmartin: Oh, are you trying to have the macro add :dynamic true to the metadata? |
| 10:02 | llasram | You can use with-meta for that too |
| 10:03 | micahmartin | yes… here's the src: |
| 10:03 | micahmartin | (defmacro with [name & body] |
| 10:03 | micahmartin | `(do |
| 10:03 | micahmartin | (let [with-component# (new-with '~name (fn [] ~@body))] |
| 10:03 | micahmartin | (declare ^:dynamic ~(symbol name)) |
| 10:03 | micahmartin | with-component#))) |
| 10:05 | llasram | micahmartin: Ahhh, yeah. So the ^ metadata stuff hapens at read time, so it's getting applied to the (symbol name) form, *not* the macro-expansion time result of that |
| 10:05 | micahmartin | yeah.. that's what I found out. |
| 10:07 | khaliG | so what are people using clojure for? i'm getting the feeling it's mainly used for web stuff, is this correct? |
| 10:07 | llasram | micahmartin: I think it'll work if you try instead something like: (declare ~(with-meta name (assoc (meta name) :dynamic true))) |
| 10:07 | micahmartin | llasram: What you suggested worked. I added the meta data to the symbol before passing it into declare |
| 10:07 | llasram | micahmartin: Awesome! |
| 10:07 | micahmartin | llasram: Thanks! |
| 10:08 | llasram | khaliG: That's a question I have too, although I don't have the same impression re: web stuff. Well, beyond the fact that "web stuff" is most of the dev work going on right now, and thus is most of what anyone is doing with anything |
| 10:14 | jcromartie | OK this is insane: http://www.jamesjohnson.me/2011/10/05/beginners-guide-to-programming.html |
| 10:14 | jcromartie | I have to imagine that a basic (sans Emacs) introduction to Clojure and Compojure would be simpler |
| 10:18 | llasram | I think the lack of a builtin (or sane) package management on OS X is the real hassle there. I think full-and-honest "get setup from scratch" instructions for anything on OS X or Windows are going to look like that |
| 10:30 | andrewclegg | hey, does anyone know if it's possible to customize the thread pool used by futures? |
| 10:36 | andrewclegg | n/m, I found a good blog on this (thanks raek) |
| 10:39 | jcrossley3 | andrewclegg: url? |
| 10:39 | andrewclegg | http://blog.raek.se/2011/01/24/executors-in-clojure/ |
| 10:41 | jcromartie | llasram: except Rails has a ton of dependencies and hand-wavy magic |
| 10:41 | jcromartie | in order to get a n00b up |
| 10:41 | andrewclegg | more like a manual way to do the same thing though, rather than a way to control futures and send-off |
| 10:42 | lnostdal_ | are there better ways of dealing with (manipulating) arguments than e.g. this: http://paste.lisp.org/display/125362 .. ? |
| 10:43 | jcrossley3 | andrewclegg: thx |
| 10:45 | lnostdal_ | (show-ModalDialog some-widget :js-options {:width 800} :on-close (alert "dialog was closed") ;; the goal is to add :modal :true to :js-options so it'll look like {:width 800 :modal :true} when passed on to show-Dialog |
| 10:48 | andrewclegg | I guess if an exception happens in some code being run by a future, it'll pop out when I deref the future, right? |
| 10:49 | gfredericks | ,@(future (throw (new Exception "POP!"))) |
| 10:49 | clojurebot | #<RuntimeException java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.Exception: POP!> |
| 10:49 | gfredericks | in a nested sort of way apparently |
| 10:49 | lnostdal_ | (let [later (future (/ 42 0))] (Thread/sleep 1000) @later) |
| 10:49 | lnostdal_ | yeah |
| 10:51 | andrewclegg | hah, yeah, should've just tested it myself :-) |
| 10:51 | raek | andrewclegg: yes, unless you have a try/catch block in the future body |
| 10:51 | andrewclegg | still getting used to how quickly you can test these hypotheses in clj... |
| 10:51 | raek | so futures are not ideal for background threads... |
| 10:52 | gu | hi, can someone please solve a doubt about leiningen? it is exposed here: http://stackoverflow.com/questions/7787911/compojure-lein-ring-in-production |
| 10:52 | raek | *background threads that should stay alive indefinitely |
| 10:52 | gfredericks | raek: are they also bad for that because they hog resources from the thread pool? Or do I misunderstand how that works? |
| 10:53 | ThreeCups | I'm new to clojure. I'm using congomongo. I'm trying to figure out the pattern/idiom for getting/using a connection to the mongodb server in a thread-safe way. congomongo has a method make-connection that returns a connection map that is to be used with a with-mongo macro (or a set-connection! method, but I'm not using this). I have a library/file/namespace (not sure which word is best here)... |
| 10:53 | ThreeCups | ...where I do something like (def db (make-connection ...)). My understanding is that db is now a Var and it will be shared by all threads. Is this correct? If that's the case, then I just need to be sure that db is a thread-safe connection. |
| 10:54 | raek | clojure uses a thread pool of unbounded size for futures, so it's safe to execute long processes in it |
| 10:54 | jcrossley3 | raek: what is the ideal for bg threads that must stay up indefinitely? |
| 10:54 | raek | hrm, well the default error handling mechanism is not ideal... |
| 10:55 | gfredericks | raek: okay, good to know |
| 10:55 | raek | I usually end up with somehting like this: https://gist.github.com/1098366 |
| 10:55 | ipostelnik | jcrossley3, the real question is what do you want to happen when your background code throws an exception |
| 10:56 | ipostelnik | you can wrap your code in a try/catch that swallows (or logs) exceptions and recurs to the start of the method |
| 10:56 | raek | ...but the default error handling mechanism for java.lang.Threads (print stacktrace to stdout) might not be what you want either |
| 10:57 | raek | you should always catch exceptions at the top level anyway (e.g. to log them) |
| 10:58 | gfredericks | (defmacro cautious-future ...) |
| 10:58 | raek | in another thread than the repl, you don't have the repl to catch them for you... |
| 10:58 | cemerick | technomancy: aside from my snark, what really happened? Does ubuntu re-repackage stuff? |
| 11:00 | jcrossley3 | ipostelnik: i thought raek was implying there was a better abstraction than futures to use for long-running tasks, but i gather he meant "better than a future using default error-handling" |
| 11:01 | raek | for initial development, using j.l.Thread might be simpler for long-running background threads, since the default error handling prints to stdout instead of saving the exception until you dereference the future |
| 11:02 | jcrossley3 | raek: cool, thx |
| 11:03 | raek | executors and their Futures have richer apis, though |
| 11:03 | raek | (e.g. you can query it if it's still running) |
| 11:08 | raek | if you send stuff to the swing thread for execution, you have the same problem with exceptions |
| 11:09 | raek | so rather than trying to make a safe variant of one of the threading apis (e.g. future), maybe you do need to have a "safety net" macro that you can easily wrap code in |
| 11:30 | todun | when I try to compile my code in emacs, I get this: C-c C-k is undefined. I've restarted emacs but still get this error. Anyone else experience this? thanks. |
| 11:35 | ljos | Does clojure have a -1 operator like CL? |
| 11:35 | gfredericks | what does that do? |
| 11:35 | cemerick | dec |
| 11:35 | gfredericks | oh it does that |
| 11:35 | cemerick | (so I presume) |
| 11:36 | cemerick | I suppose it might negate, in which case (partial * -1) |
| 11:36 | gfredericks | I also thought he could have meant ##(- 7), but dec seems much more plausible |
| 11:36 | lazybot | ⇒ -7 |
| 11:36 | cemerick | …if you don't care about boxing |
| 11:36 | ljos | I think dec is what I am looking for. |
| 11:37 | cemerick | gfredericks: heh, thats a lot more sensible, as long as you've got only one arg :-| |
| 11:37 | gfredericks | cemerick: how often do you define multi-arg negation functions? :) |
| 11:38 | gfredericks | (partial * -1) also does weird stuff if you give more than one arg |
| 11:38 | cemerick | gfredericks: You don't, but - is multi-arg :-) |
| 11:38 | cemerick | true enough |
| 11:38 | gfredericks | (fn [x] (- x)) to be safe |
| 11:38 | cemerick | this is why I try to avoid quickest-keyboard-in-the-west irc conversations |
| 11:39 | cemerick | (and yet…) |
| 11:39 | gfredericks | :) |
| 11:44 | khaliG | it would help if ljos got the right function which is 1- not -1 :) |
| 11:51 | carllerche | technomancy: is it sane to try to run leiningen w/ 1.3 projects right now? |
| 11:54 | andrewclegg | umm... I'm trying to make a vector of ints (not longs) to pass into java |
| 11:54 | andrewclegg | or rather to put into an arraylist to pass into java |
| 11:55 | andrewclegg | but I'm getting an arraylist of longs |
| 11:55 | andrewclegg | (def resources (conj (vector-of :int) 1 2 3)) |
| 11:56 | andrewclegg | then (def foo (ArrayList. resources)) |
| 11:56 | andrewclegg | would've thought that would give me an ArrayList<Long> but they're Integers -- any ideas? |
| 11:56 | duck1123 | carllerche: lein works fine with 1.3 projects |
| 11:57 | duck1123 | lein still uses it's own version though |
| 11:57 | carllerche | I'm getting a thrown exception when I run `lein test`… I submitted an issue |
| 12:00 | pjstadig | andrewclegg: you mean you would've thought that would give you an ArrayList<Integer>? |
| 12:01 | andrewclegg | err yeah, sorry |
| 12:01 | andrewclegg | reverse of what I said |
| 12:01 | pjstadig | well generics are a fabrication of the java compiler |
| 12:01 | andrewclegg | I'm after an ArrayList<Integer> |
| 12:01 | pjstadig | so it's really an array list of objects |
| 12:01 | andrewclegg | ok, well I'm after an arraylist with ints in :-) |
| 12:01 | pjstadig | the things you're putting in are Integers |
| 12:01 | pjstadig | andrewclegg: which version of clojure? |
| 12:01 | andrewclegg | 1.3 |
| 12:02 | andrewclegg | longs by default now right? |
| 12:02 | pjstadig | so you need to do something like (def resources (conj (vector-of :int) (int 1) (int 2) (int 3))) |
| 12:02 | pjstadig | yeah longs are default |
| 12:02 | andrewclegg | oh, I assumed the (vector-of :int) would create a vector that only accepted ints, for some reason |
| 12:03 | andrewclegg | http://clojuredocs.org/clojure_core/clojure.core/vector-of makes it look like that |
| 12:05 | pjstadig | i've never used vector-of |
| 12:07 | andrewclegg | ,(.getClass (int 3)) |
| 12:07 | clojurebot | java.lang.Long |
| 12:07 | andrewclegg | wtf? ^ |
| 12:07 | andrewclegg | ,(.getClass (short 3)) |
| 12:07 | clojurebot | java.lang.Short |
| 12:07 | andrewclegg | (sorry) |
| 12:08 | andrewclegg | why does (int 3) return a long? |
| 12:08 | pjstadig | https://groups.google.com/d/msg/clojure-dev/1kkjqq8Yois/E0nsEY1XcEAJ |
| 12:09 | pjstadig | hmm |
| 12:09 | pjstadig | thought that might be relevant, but maybe it isnt |
| 12:09 | hiredman | andrewclegg: do you have some kind of actual problem? |
| 12:10 | andrewclegg | hiredman: sadly yes. trying to construct an ArrayList of Integers to pass into a Java method |
| 12:11 | dnolen | andrewclegg: int does not return a long. |
| 12:11 | andrewclegg | so I see |
| 12:11 | hiredman | andrewclegg: then create some integers |
| 12:11 | dnolen | andrewclegg: int casts to a primitive int. |
| 12:11 | pjstadig | andrewclegg: you may just skip the primitives then |
| 12:11 | pjstadig | ,(map type (java.util.ArrayList. [(Integer/valueOf 1)])) |
| 12:11 | clojurebot | (java.lang.Integer) |
| 12:12 | andrewclegg | ok, thanks |
| 12:16 | andrewclegg | that worked -- thanks everyone |
| 12:16 | gfredericks | cemerick: there's a stray "&" in your new blog post, in the code snippet below "so let's have it:" |
| 12:22 | cemerick | gfredericks: thanks, fixed |
| 12:23 | gfredericks | \o/ |
| 12:35 | ipostelnik | in lein, is it possible to include env variables in the jar manifest ? |
| 12:35 | ipostelnik | I'm trying to get the build number into the manifest |
| 12:38 | technomancy | cemerick: apparently the packaging for asm changed in debian unstable, and the corresponding fixes for lein didn't get synced into ubuntu |
| 12:38 | technomancy | something getting split into multiple jars |
| 12:39 | zilti | "Write a function which allows you to create function compositions. The parameter list should take a variable number of functions, and create a function applies them from right-to-left." That does mean that I have to do (apply last second-to-last) right? "Wrong number of args (0) passed" |
| 12:39 | cemerick | technomancy: so it wasn't actually a repackaging |
| 12:39 | technomancy | well... clojure bundles its own asm to prevent things like this |
| 12:39 | cemerick | wait, why is asm relevant at all? |
| 12:39 | cemerick | Right, that's what I was getting at. |
| 12:40 | technomancy | but they had to undo that to fit with policy |
| 12:40 | cemerick | waitaminute :-) |
| 12:40 | cemerick | the clojure package on debian has asm ripped out of it? |
| 12:40 | technomancy | it's actually not lein-specific; anything using the clojure package is broket |
| 12:40 | technomancy | I think so =\ |
| 12:40 | cemerick | :-D |
| 12:40 | cemerick | oy vey |
| 12:41 | technomancy | total culture clash |
| 12:43 | cemerick | Not sure it's a culture thing. |
| 12:43 | cemerick | What if Clojure shipped with modified asm? |
| 12:44 | cemerick | (probably wouldn't be allowed into the official repositories, I suppose) |
| 12:44 | technomancy | well, if they called it out as an explicit fork probably would be fine |
| 12:44 | technomancy | it's just that a lot of people bundle stuff like that out of laziness, specifically because they don't have a good dependency mechanism |
| 12:45 | technomancy | and that's what the policy is meant to prevent |
| 12:45 | TimMc | What is the asm? |
| 12:45 | technomancy | TimMc: bytecode generation library |
| 12:46 | zilti | TimMc: Apache asm is a library to modify java bytecode. |
| 12:46 | TimMc | ok |
| 12:46 | hiredman | it |
| 12:46 | hiredman | asm is not an apache project as far as I know |
| 12:46 | hiredman | apache has something else |
| 12:46 | hiredman | bcl? |
| 12:47 | hiredman | bcel |
| 12:47 | joegallo | i think bcel is built on asm |
| 12:47 | cemerick | bytecode engineering library, yeah? |
| 12:47 | hiredman | joegallo: interesting |
| 12:47 | joegallo | or maybe i'm confusing bcel and cglib |
| 12:48 | joegallo | i got it backwards |
| 12:48 | joegallo | cglib uses bcel |
| 12:49 | joegallo | (or so claims the cglib website) |
| 12:50 | joegallo | looking at the maven info, that claim seems to be false |
| 12:51 | TimMc | "SparseStringArrayVectorDeserializer" <- just seen in codebase |
| 12:52 | babilen | cemerick: I guess that in that case the clojure asm would have to be released and packaged seperately |
| 12:54 | cemerick | yeah |
| 12:54 | cemerick | babilen: I generally don't think it's right for downstream packagers to mess with whatever original authors have done. |
| 12:55 | cemerick | though I understand the motivations / priorities, despite the smoke I throw about it. |
| 12:55 | babilen | cemerick: I beg to differ, but that is probably due to the same culture clash :) |
| 12:55 | technomancy | anyway thanks to babilen it does work fine in debian. it's just that ubuntu goofed up. |
| 12:56 | TimMc | Nothing's new there. -.- |
| 12:57 | cemerick | babilen: do you differ with my opinion, or the notion that I understand the motivations? ;-) |
| 12:57 | TimMc | <-- increasingly pissed-off Ubuntu user |
| 12:57 | babilen | cemerick: hehe, no :) |
| 12:57 | babilen | cemerick: I mean the opinion, not your understanding |
| 12:58 | cemerick | babilen: I can reasonably believe either! :-D |
| 12:58 | cemerick | I'm JVM-centric, so what I care about is likely always going to run counter to distro / repository maintainers. |
| 12:59 | hiredman | jvm on the metal! |
| 12:59 | cemerick | still in the lab, no? |
| 13:00 | babilen | Probably, even though I believe that having 1000 identical instances of the same library on one system is not necessarily a good thing. But anyway, we have to live with those different cultures and the packaging tools ease a lot of the pain that is associated with it. |
| 13:00 | technomancy | I'm ok with tweaks like that for application-level packages like lein and its dependencies. I would balk if developers were hacking against it, but they're not; they're getting clojure directly from mvn central. |
| 13:01 | technomancy | libraries for end user applications vs libraries for developers are vastly different use cases; most people tend to lump them together. |
| 13:01 | babilen | +1 |
| 13:01 | gfredericks | TimMc: I just tried to upgrade 11.04 -> 11.10 last night. Looked at it this morning and it had bogged down on a download task because the wifi connection had died for some reason. Couldn't turn the connection back on even by plugging in ethernet. |
| 13:07 | carllerche | Are there any guarantees regarding the key order when iterating a map? |
| 13:07 | TimMc | gfredericks: But it keeps getting more shiny! At least they are working on that. |
| 13:07 | TimMc | carllerche: No. |
| 13:07 | gfredericks | TimMc: I'm strongly considering giving up on that upgrade and installing debian |
| 13:08 | gfredericks | carllerche: I think only that (keys) returns the same order as (vals) |
| 13:08 | nickmbailey | carllerche: you can use a sorted map |
| 13:09 | gfredericks | TimMc: if "shiny" means "GUI I don't like" and "perpetually buggy" then I can do without it |
| 13:09 | technomancy | gfredericks: I tried that a few months ago. Found the polish to be lacking, but I feel like I have a lot more in common with the target Debian user. |
| 13:10 | gfredericks | technomancy: so you're content with debian? |
| 13:10 | cemerick | technomancy: is lein an application or a library for authors of plugins? |
| 13:11 | technomancy | gfredericks: no, I ended up going back. the attitude towards non-free drivers required for basic functionality pissed me off, plus there were a few bugs with the USB auto-mounting stuff. |
| 13:11 | technomancy | cemerick: good question. I don't have a great answer right now, but 2.0 will definitely address that. |
| 13:12 | technomancy | cemerick: I briefly considered retroactively explicitly defining a public API, but I think for 1.x that's a lost cause. |
| 13:12 | cemerick | technomancy: Yeah, I know. :-) That was a weak rhetorical challenge to the notion of library management being different for apps than libraries. |
| 13:13 | raek | carllerche: only that (keys m) and (vals m) will traverse the etries in the same order |
| 13:13 | technomancy | cemerick: I was hoping not to get called out on that since I realized it was a bit sloppy =) |
| 13:15 | technomancy | seancorfield: do the java.jdbc tests require a local mysql server? |
| 13:16 | Raynes | I hate new releases. |
| 13:16 | gfredericks | Raynes: only old releases from now on! |
| 13:16 | Raynes | It's never about updating your own projects. It's about updating everyone elses! |
| 13:16 | Raynes | You're all lazy, you know. All of you. |
| 13:16 | Raynes | Should be ashamed. |
| 13:18 | chouser | I think I'm still unwilling to accept that making code public means I'm promising to maintain it forever. |
| 13:18 | chouser | Maybe that's naive of me. |
| 13:18 | technomancy | chouser: that's what 0.x.0 releases are for! =) |
| 13:19 | chouser | I thought maybe having *no* release, and just code on github would be sufficiently standoffish. But no, I've gotten dinged for that too, with "difficulty to install" and "poor docs" added to the out-of-dateness complaint. |
| 13:20 | technomancy | chouser: that's usually just a sign that your code is compelling enough that people are willing to put up with more crap to use it. =) |
| 13:21 | chouser | heh. I guess that's the silver lining. |
| 13:21 | technomancy | maybe if you start threatening to hand out commit rights that would put a damper on things. |
| 13:22 | chouser | ha! |
| 13:22 | technomancy | it's worked all right for me on swank |
| 13:22 | technomancy | this is about finger tree, right? |
| 13:22 | chouser | technomancy: ah, but not lein, now has it. I bet you have a queue full of well-meant patches demanding your attention there... |
| 13:23 | chouser | technomancy: oh, I think finger trees are ok. No, data.xml needs love but I'm just too worried about my conj talk to give it any time. |
| 13:23 | technomancy | chouser: related observation: the less polished the overall experience, the more likely people are to think they can help. |
| 13:24 | technomancy | if you come across as having it all together, it's more inviting for users but sometimes a bit less for contributors |
| 13:24 | Raynes | You're worried about your talk? Seriously? You could walk up to the microphone and fart and people would applaud. I'm the one who has to worry. |
| 13:24 | technomancy | (probably not consciously) |
| 13:25 | chouser | Raynes: goodness, that sounds harder than anything I'm considering. |
| 13:25 | gfredericks | "Audible Finger Trees" |
| 13:25 | babilen | technomancy: Hmm, btw. Do you have an ETA for the 2.0 release? (Just want to plan accordingly) |
| 13:26 | technomancy | babilen: if it's usable (not released) in 6 months I will be surprised. |
| 13:26 | technomancy | I do plan on at least one more 1.x release in the next 2 months or so, but that will be pretty minor. |
| 13:26 | babilen | technomancy: Wonderful |
| 13:27 | technomancy | babilen: of course I keep thinking "this will be the last 1.x" release and keep being wrong, so be aware of that. =) |
| 13:29 | Raynes | cake should be the Chrome to your 2010 firefox and start releasing things every 3 days. |
| 13:30 | babilen | technomancy: That is all fine, but I have this feeling that the 2.0 release will take a bit more packaging time than all the 1.x ones. Just want to plan accordingly so the version in the repos does not lag behind. |
| 13:37 | zilti | What are the big new things planned for 2.0? |
| 13:40 | Raynes | zilti: I expect that 2.0 will park your car for you. |
| 13:41 | technomancy | zilti: there's a thread on it here: http://groups.google.com/group/leiningen/browse_thread/thread/1223cd092b83f007 |
| 13:41 | technomancy | zilti: the big things are switching the underlying mvn infrastructure and moving towards running more code in a single process |
| 13:41 | technomancy | as well as a better split between internals and public API |
| 13:42 | zilti | Thanks. Well, parking my car is a nice gimmick, but I don't have one. Damn. Now I have to buy one. ;) |
| 13:45 | cemerick | chouser, Raynes: we have to talk at the Conj? I thought I was entering a raffle. |
| 13:45 | Raynes | You should have seen the look on my face when I was told otherwise. |
| 13:46 | ibdknox | I entered the raffle ;) |
| 13:47 | ghiu | why doesn't the quote work? (let [] (-> 3 (+ 2))) => (let [x '(+ 2)] (-> 3 x)) |
| 13:47 | gfredericks | wow |
| 13:47 | gfredericks | that's creative |
| 13:47 | gfredericks | (-> 3 x) will immediately "expand" to (x 3) |
| 13:47 | cemerick | ibdknox: the only contest where entrants aren't sure whether they want to win or not :-P |
| 13:48 | fliebel | cemerick: re partial et all: Yuk, nested calls *will* be ugly, right? |
| 13:48 | cemerick | fliebel: Don't think so. Where? |
| 13:48 | ibdknox | cemerick, haha it's true.. damn those double-edged swords |
| 13:49 | ghiu | gfredericks: because it's a macro, right? |
| 13:49 | fliebel | cemerick: What you said in point one. |
| 13:50 | raek | ghiu: (let [x '(+ 2)] (-> 3 x)) = (let [x '(+ 2)] (-> 3 (x))) = (let [x '(+ 2)] (x 3)) = ('(+ 2) 3) |
| 13:50 | cemerick | fliebel: Right, they're a problem, if you don't put each fn definition within a closure that provides references to all of the original functions. |
| 13:50 | raek | ghiu: '(+ 2) is a list, and you can't call a list as a function |
| 13:50 | cemerick | (which I'm doing at the moment in clutch) |
| 13:51 | Raynes | cemerick: I read that as 'church'. I was about to ask you if you were imbuing your code with the holy spirit. |
| 13:51 | fliebel | cemerick: What if you take it a step further and *gulp* walk the AST to replace all calls with the partial one? |
| 13:51 | chouser | It doesn't help that I'm pretty sure that, of all the people dabbling with ClojureScript, I've done only the least interesting things. |
| 13:52 | cemerick | fliebel: That's what I foolishly started doing. It's not fun. :-) |
| 13:52 | hiredman | you want letmacro |
| 13:52 | fliebel | It's kinda like doto. |
| 13:52 | hiredman | well, no |
| 13:53 | hiredman | fliebel: that won't work |
| 13:53 | srid | ,(clojure.java.shell/sh "ls -l") |
| 13:53 | zilti | Can someone help me? I don't know what's wrong with this: https://gist.github.com/1293255 |
| 13:53 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.java.shell> |
| 13:53 | srid | fails. not sure why. |
| 13:53 | hiredman | fliebel: I assume you are talking about cemerick's blog post? |
| 13:53 | srid | ,(slurp (.getInputStream (.exec (Runtime/getRuntime) "ls -l"))) ;; this works |
| 13:53 | clojurebot | #<AccessControlException java.security.AccessControlException: access denied (java.io.FilePermission <<ALL FILES>> execute)> |
| 13:53 | cemerick | Raynes: he lays me down in green threads, he replicates my databases. |
| 13:53 | fliebel | hiredman: yes |
| 13:53 | Raynes | Amen. |
| 13:53 | srid | clojure.java.shell/sh uses Runtime.exec as per documentation, but it is behaving differently |
| 13:54 | hiredman | fliebel: walking the ast will get you lexical changes, just like if you lexically shadowed the names, but won't work dynamically |
| 13:54 | cemerick | Raynes: We're all going to hell. ;-) |
| 13:54 | hiredman | (with-whatever (foo)) |
| 13:54 | raek | srid: have you tried this? (sh "ls" "-l") |
| 13:54 | hiredman | at this point you may as well use the state or reader monad |
| 13:55 | hiredman | :/ |
| 13:55 | srid | raek: oh? I thought the arguments (after "sh") must be one of :in, :out, :dir or :env - http://richhickey.github.com/clojure/clojure.java.shell-api.html |
| 13:55 | Raynes | http://clojure.github.com/clojure/clojure.java.shell-api.html |
| 13:56 | Raynes | I'm not entirely certain how, but it might be useful to make clojurebot throw down a snarky but helpful remark when people link to richhickey.github.com/clojure |
| 13:57 | Raynes | Or perhaps just a helpful one. |
| 13:57 | fliebel | &(letfn [(foo [conf bar] (println conf bar)) (bar [conf baz] (println conf baz))] (doto {:aap "noot"} (foo 1) (bar 2))) |
| 13:57 | lazybot | ⇒ {:aap noot} 1 {:aap noot} 2 {:aap "noot"} |
| 13:58 | srid | raek: i have my wrapper that then calls `(sh cmd args :return-map true) :out))` but this is incorrect as `args` is a list of arguments. how would I fix this? (previously I did not have to pass 'args' at all, and it worked) |
| 13:58 | srid | (the wrapper accepts both cmd and args as parameter -- [cmd & args] |
| 13:59 | seancorfield | technomancy: no, the java.jdbc tests don't require a local mysql server - unless you add :mysql to the list of DBs to test in test_jdbc.clj |
| 14:00 | gfredericks | I don't imagine there's an easy way to do a 'lein checkouts'-equivalent setup with this maven project that depends on a lein project is there? |
| 14:00 | fliebel | hiredman, cemerick: Works, right? ^^ |
| 14:01 | cemerick | fliebel: sure, but…so? |
| 14:01 | technomancy | seancorfield: cool; thanks |
| 14:02 | technomancy | seancorfield: in general, the tests against the in-process DBs are sufficient? |
| 14:02 | fliebel | cemerick: Hm, dunno. Not flexible enough I guess, but you can apply a couple of db fns that way with the conf only in one place. |
| 14:03 | seancorfield | i run tests against mysql locally when i'm working on it |
| 14:03 | cemerick | fliebel: Right; the same applies to any API that takes "configuration" as a first arg (including clutch 0.3.0 at the moment) |
| 14:03 | seancorfield | but the build server does not (yet) have a mysql instance handy |
| 14:03 | cemerick | e.g. (doto "localhost" (put-document …) (put-document …) (get-view …)), etc |
| 14:04 | seancorfield | eventually i expect it to have more tests against more DBs but it all depends on Clojure/core time to set stuff up around build.clojure.org |
| 14:04 | cemerick | doto is just a macro though — certainly not equivalent to dynamic scope |
| 14:04 | hiredman | right |
| 14:04 | srid | raek: my solution: ((apply sh (flatten [cmd args :return-map true])) :out)) |
| 14:04 | hiredman | and that is almost exactly the reader monad |
| 14:04 | srid | i had to read sh's source to find out how args are being parsed |
| 14:05 | cemerick | Being a proper dullard, I've never internalized the use of monad names as identifiers of common patterns. |
| 14:06 | fliebel | Okay, you win. Still don't like the fn macro though. |
| 14:06 | hiredman | no problem, I am just pointing out where this is heading, in case some wants to make a u-turn |
| 14:06 | cemerick | fliebel: sorry, wasn't trying to 'win' :-) |
| 14:07 | technomancy | seancorfield: have you seen http://travis-ci.org? |
| 14:07 | fliebel | cemerick: Haha, I didn't mean it like that. More like, I don't know anything better. |
| 14:09 | fliebel | I'd love to have a perfect solution though. |
| 14:10 | hiredman | the reader monad is the state monad without the ability to write new state, so e.g. you have configuration values that you read and those values get passed everywhere |
| 14:14 | gfredericks | fliebel: macros writing macros? |
| 14:15 | fliebel | gfredericks: Even worse. |
| 14:15 | fliebel | What if you wrapped the binding in a trampoline, and converted the whole shebang to CPS, then you could drop out of the binding for inter-api calls. |
| 14:15 | fliebel | ... maybe |
| 14:15 | hiredman | … |
| 14:16 | ghiu | guys, i need to do this: (-> mylist (function1 a b) (function2 c d) (function3 e f).. ), but i need to generate dynamically how many functions and their values. what's the way to go? |
| 14:16 | cemerick | helluva can of worms I've opened up :-P |
| 14:16 | gfredericks | ghiu: do it without a macro |
| 14:16 | ghiu | hmmm |
| 14:17 | gfredericks | ghiu: use reduce or something like that |
| 14:17 | ghiu | ok, i'll try |
| 14:17 | ghiu | i've never used macros :$ |
| 14:17 | seancorfield | technomancy: i had not seen travis... looks very ruby focused? |
| 14:17 | ghiu | (i'm on my first week of clojure :P) |
| 14:17 | gfredericks | ghiu: -> is a macro |
| 14:17 | technomancy | seancorfield: it's primarily ruby, but it has clojure support. |
| 14:18 | ghiu | i know what macros are, just i've never written any in clojure |
| 14:18 | technomancy | not sure if it'd be appropriate for jdbc, just thought it was interesting |
| 14:18 | seancorfield | technomancy: and lots of DB support? |
| 14:18 | gfredericks | ghiu: if you have a list of [f args] pairs, you could do (reduce (fn [v [f args]] (apply f v args)) init-val farg-list) |
| 14:18 | technomancy | seancorfield: I think so |
| 14:18 | seancorfield | i'll put it on my todo list then :) |
| 14:19 | fliebel | cemerick: Meh, how many inter-api call do you really use. I think it's fine in practice. |
| 14:20 | zilti | What's the eager "equivalent" to map? |
| 14:20 | gfredericks | doseq |
| 14:20 | gfredericks | sorta |
| 14:20 | Raynes | &(doc doall) |
| 14:20 | lazybot | ⇒ "([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. doall can be used to force any effects. Walks through the ... https://gist.github.com/1293343 |
| 14:20 | cemerick | fliebel: some alternatives have been suggested in the blog comments and elsewhere. We'll see what percolates up. :-) |
| 14:21 | technomancy | seancorfield: are you planning another 0.1.x release before 0.2.0? |
| 14:21 | ghiu | gfredericks: i'm trying with reduce then |
| 14:21 | ghiu | gfredericks: thanks |
| 14:21 | gfredericks | ghiu: yep |
| 14:21 | seancorfield | technomancy: probably several |
| 14:21 | technomancy | cool |
| 14:22 | seancorfield | the 0.1.0 -> 0.2.0 path will be evolving the new API that Clojure/core seem to want |
| 14:22 | seancorfield | (don't take that the wrong way: i asked about the path to 1.0.0 releases and they gave some great feedback) |
| 14:23 | seancorfield | so consider 0.1.0 the first full stable release of a pure replacement for c.c.sql :) |
| 14:23 | technomancy | makes sense |
| 14:25 | fliebel | cemerick: Oh, right, I like the generated namespace. |
| 14:26 | cemerick | gfredericks has another idea that's much simpler than all the rest, though I've not considered it entirely. He has yet to comment, tho. :-) |
| 14:27 | gfredericks | I guess I gotta put it in a gist...no pretty code in the comments, right? |
| 14:28 | technomancy | seancorfield: have you considered providing a default mapping for :subprotocol -> :classname? |
| 14:28 | technomancy | having to specify both seems like unnecessary boilerplate |
| 14:29 | seancorfield | i had not considered that and i agree it sounds like a good idea - JIRA ticket pls! |
| 14:29 | technomancy | will do |
| 14:37 | gfredericks | cemerick: okay done |
| 14:40 | cemerick | gfredericks: the (not (identical? …)) bit was a nice touch. Will think about it, thanks. |
| 14:50 | technomancy | seancorfield: JDBC-22 is about inferring :classname and JDBC-21 is about accepting a string arg for the connection parameter. OK to make the latter depend upon the former? |
| 14:50 | seancorfield | sure |
| 14:51 | seancorfield | thx for the tix! |
| 14:51 | technomancy | k, patch is in for 22 |
| 14:51 | technomancy | no problem |
| 14:58 | zakwilson | UnsupportedDataTypeException with Apache Commons Mail is a really nasty little problem. It sure would be nice if there was a good way to send email that never ran in to this. |
| 15:00 | zilti | zakwilson: JavaMail? |
| 15:00 | zakwilson | I can't remember why I rejected that, but I think it was a good reason. |
| 15:01 | zilti | I remember it being dead-easy to use |
| 15:01 | zilti | What's the difference between next and rest? |
| 15:02 | gfredericks | cemerick: yeah, that was the new thought |
| 15:02 | raek | zilti: (next x) is like (seq (rest x)) |
| 15:02 | seancorfield | technomancy: patch for 22 applied and pushed |
| 15:02 | raek | zilti: seq is guaranteed to return nil if the sequence is empty |
| 15:02 | jcromartie | ,(doc rest) |
| 15:02 | zilti | ok thanks |
| 15:02 | technomancy | groovay |
| 15:02 | clojurebot | "([coll]); Returns a possibly empty seq of the items after the first. Calls seq on its argument." |
| 15:09 | ejackson | is there a way to get the output of (macroexpand-1 ...) into a test ? Any ideas of which libraries I should go trawl to find an example ? |
| 15:09 | hiredman | ,(macroexpand-1 '(binding [x y] 1)) |
| 15:10 | clojurebot | (clojure.core/let [] (clojure.core/push-thread-bindings (clojure.core/hash-map (var x) y)) (try 1 (finally (clojure.core/pop-thread-bindings)))) |
| 15:10 | ejackson | hiredman: yes, but in an (is ...) block it doesn't expmand. |
| 15:11 | gfredericks | ejackson: (let [form (expand ...)] (is (= form ...))) |
| 15:11 | ejackson | gfredericks: nice idea, lemme try that. |
| 15:11 | gfredericks | ejackson: is is a macro that can muddle things up, so as long as you do all your macro-ey things outside it should be okay |
| 15:11 | ejackson | i already tried passing it through a function in a similar vein |
| 15:12 | gfredericks | ejackson: ultimately any test should be reducible to (let [boolean (...)] (is boolean)) |
| 15:12 | gfredericks | except for error reporting I guess |
| 15:12 | ejackson | k |
| 15:14 | ejackson | no dice |
| 15:14 | ejackson | (let [f (macroexpand-1 '(rel/chain :author))] |
| 15:14 | ejackson | (is (= f :x))) |
| 15:14 | ejackson | results inFAIL in (test-defrelation) (relation.clj:17) |
| 15:14 | ejackson | expected: (= f :x) |
| 15:14 | ejackson | actual: (not (= (rel/chain :author) :x)) |
| 15:15 | gfredericks | that weird. |
| 15:15 | ejackson | rel/chain should expand to something like (clojure.core/-> (clojureql.core/table relation.database/db :authors)) |
| 15:16 | hiredman | is rel/chain really a macro? |
| 15:16 | hiredman | ,(macroexpand-1 '(x y)) |
| 15:16 | clojurebot | (x y) |
| 15:16 | ejackson | hiredman: yup |
| 15:16 | ejackson | (defmacro chain |
| 15:16 | ejackson | "This constructs a chain from keywords representing relations. EG |
| 15:16 | ejackson | (chain :author :post :comment)" |
| 15:16 | ejackson | [base & rest] |
| 15:16 | ejackson | `(-> (cql/table db/db ~(rel-to-table base)) |
| 15:16 | ejackson | ~@(map make-ns-qualified (partition 2 1 (cons base rest))))) |
| 15:17 | hiredman | please don't paste multiline chunks of text |
| 15:17 | ejackson | hiredman: yeah, I'm sorry. |
| 15:17 | ejackson | i'm trying to get you guys a github link to that |
| 15:18 | ejackson | https://github.com/ejackson/relation/blob/master/src/relation/relation.clj#L145 |
| 15:20 | ejackson | the failing test in question is at https://github.com/ejackson/relation/blob/master/test/relation/test/relation.clj#L15 |
| 15:23 | ejackson | the comparison is generated by expanding the macro in the test namespace, so I think its an interaction with the (is macro in clojure.test. |
| 15:28 | gfredericks | oh wait |
| 15:28 | gfredericks | deftest is a macro too |
| 15:28 | gfredericks | try outside that? |
| 15:29 | gfredericks | I believe I remember having to do that once |
| 15:29 | ejackson | ok. |
| 15:29 | ejackson | found something odd, as it does work with -> Perhaps namespaces or something. |
| 15:30 | ejackson | https://gist.github.com/1293529 expands correctly |
| 15:33 | ejackson | gfredericks: yes, pulling the macroexpand into a (def ...) outside the deftest does work. |
| 15:33 | ejackson | thank you. |
| 15:34 | gfredericks | ejackson: np; you could even avoid the def with (let [f (macroexpand-1 ...)] (deftest ...)) |
| 15:34 | ejackson | gfredericks: yes, that's even better. |
| 15:35 | ejackson | I'll try chase down the namespace idea |
| 15:36 | jweiss | can someone point me in the right direction for clojure1.3 upgrade? looks like c.c.prxml is not being maintained - doesn't look difficult to fix, is there doc on how i get it into the modular contrib? (or is there a replacement for prxml i don't know about) |
| 15:38 | amalloy | jweiss: data.xml |
| 15:38 | amalloy | no official release as chouser is busy and i am maven-clueless, but it works and a number of people have put private forks on clojars |
| 15:40 | ejackson | gfredericks: hm. its to do with require. check out https://gist.github.com/1293529 |
| 15:42 | gfredericks | ejackson: it sounds like the symbols get resolved in a different namespace for some reason |
| 15:42 | gfredericks | no clue why that would happen, but can't think of anything more plausible |
| 15:45 | ejackson | gfredericks: ha, solved (not by me !) |
| 15:45 | gfredericks | yes? |
| 15:45 | ejackson | ns uses an alias for the namespace in requrie |
| 15:45 | ejackson | and deftest and is are macros |
| 15:46 | ejackson | so if I use syntax unquote, as in (is (= (macroexpand-1 `(rel/min-macro 1)) {:a 1})) then it expands the whole thing |
| 15:46 | gfredericks | ejackson: that's what I would expect. I still don't know why that would be required though. Normally you don't have to worry about this when using somebody else's macro |
| 15:47 | ejackson | its because rel is an alias |
| 15:47 | ejackson | so it doesn't expand properly (or so I'm told) |
| 15:47 | gfredericks | i.e., IF indeed the symbols are resolved in another namespace, then backquoting would certainly circumvent the problem. But I still don't know why they would be resolved in another namespace |
| 15:48 | gfredericks | ejackson: could you reproduce the behavior using your own macro instead of deftest/is? |
| 15:48 | ejackson | lemme try. |
| 15:49 | gfredericks | ejackson: try a simple macro like (defmacro rev-form [form] (reverse form)) |
| 16:09 | ejackson | gfredericks: see the difference in how they expand: https://gist.github.com/1293529 |
| 16:13 | ejackson | so somewhere along the line ' gives up and gives you just the symbol, whereas ` carries on expanding. |
| 16:14 | ejackson | anyway, I'm shattered, catch you all tomorrow. |
| 16:16 | gfredericks | oh well. even a mystery. |
| 16:16 | gfredericks | s/even/ever |
| 16:20 | zilti | Now that's weird: |
| 16:20 | zilti | ,(some true? '((= 5 5) false false)) |
| 16:20 | clojurebot | nil |
| 16:20 | zilti | ,(some true? [(= 5 5) false false]) |
| 16:20 | clojurebot | true |
| 16:20 | hiredman | what is weird? |
| 16:20 | gfredericks | zilti: ##(true? '(= 5 5)) |
| 16:20 | lazybot | ⇒ false |
| 16:20 | gfredericks | vs ##(true? (= 5 5)) |
| 16:20 | lazybot | ⇒ true |
| 16:21 | zilti | ,(some true? ((= 5 5) false false)) ;doesn't work |
| 16:21 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.IFn> |
| 16:21 | hiredman | of course not |
| 16:21 | gfredericks | zilti: I think what you're trying to do is ##(some true? (list (= 5 5) false false)) |
| 16:21 | lazybot | ⇒ true |
| 16:21 | zilti | yeah. Always thought '( is short for (list |
| 16:21 | gfredericks | zilti: when you quote the list, everything inside gets quoted too |
| 16:22 | gfredericks | zilti: not at all :) |
| 16:22 | zilti | Seems like ^^ |
| 16:22 | gfredericks | '(foo bar) is short for (quote (foo bar)) |
| 16:22 | zilti | How to unquote btw? |
| 16:22 | zilti | inside a '( |
| 16:22 | hiredman | stop quoting stuff |
| 16:22 | Bronsa | lol |
| 16:22 | zilti | lol |
| 16:23 | gfredericks | zilti: yeah, if you want a list literal then a vector is almost always a worthy substitute |
| 16:23 | gfredericks | ,(some true? [(= 5 5) false false]) |
| 16:23 | clojurebot | true |
| 16:24 | zilti | And it is easier to read. |
| 16:24 | llasram | ,(some true? `(~(= 5 5) false false)) |
| 16:24 | clojurebot | true |
| 16:24 | gfredericks | see you don't want to be messing with tildes |
| 16:25 | zilti | except in defmacro I guess |
| 16:25 | llasram | Yeah, I agree vectors capture most of the non-mcaro uses for syntax-quote. Just being completionist :-) |
| 16:27 | zilti | Is it somehow possible to see the shortest public solution to a 4clojure problem? Codegolf shows me my score and a chart but no way to see other solutions |
| 16:29 | robermann | afaik you can see the solutions of "followed" people |
| 16:29 | zilti | Yes, but only those? |
| 16:29 | robermann | yes |
| 16:29 | robermann | i suggest to you darren's solution |
| 16:29 | robermann | solutions |
| 16:31 | robermann | often they are very short, although not among the more readble imho |
| 16:32 | zilti | I've just seen at the tictactoe problem that they also aren't among the "universal solutions" but only solve the exact tests. |
| 16:34 | robermann | yes, it can happen :) |
| 16:36 | amalloy | zilti: are you talking about one of darren's solutions? i don't think he has any intentionally-incomplete solutions |
| 16:38 | zilti | amalloy: Yes, about his solution to problem 73 |
| 16:39 | zilti | Maybe I just can't read it |
| 16:39 | amalloy | zilti: apparently. he solves every possible configuration |
| 16:54 | robermann_ | anyone here using Midje? |
| 16:54 | jweiss | amalloy: do you know if clojure.data.xml supports emitting CDATA? |
| 16:54 | amalloy | jweiss: i don't think it does |
| 16:55 | jweiss | ah nuts |
| 16:55 | amalloy | actually though, i think it may wrap everything in cdata where necessary? |
| 16:56 | jweiss | amalloy: i'm giving it prxml-like input and wrapping with sexp-as-element - how should i tell it it's cdata? |
| 16:56 | jweiss | i could use a different input i guess |
| 16:56 | jweiss | i'll try just removing the cdata tag |
| 16:57 | amalloy | jweiss: unless you're trying to hide one xml document inside another as "just some characters, nothing to see here" you should be marking elements as if they were cdata |
| 16:58 | jweiss | amalloy: i'm just trying to put a stacktrace in a junit-style xml doc |
| 16:58 | jweiss | all the other junit-style xml out i've seen uses cdata for that |
| 16:58 | amalloy | god, junit has xml stacktraces? i guess i'm glad i never got that deep |
| 16:59 | jweiss | amalloy: no, it's not xml formatted |
| 16:59 | jweiss | just the text |
| 16:59 | jweiss | but it's inside a <failure > </failure> tag |
| 16:59 | amalloy | jweiss: you shouldn't need to mark it as cdata unless it has stuff inside it which could be interpreted as xml. and my understanding is that data.xml will escape it in that case |
| 17:00 | jweiss | amalloy: if you don't mark it as cdata it loses all the whitespace formatting, doesn't it? |
| 17:01 | jweiss | xml is normally rendered with some kind space-normalizing function, unless you use cdata |
| 17:02 | jweiss | i don't think i have a choice here anyway, because stacktrace messages could have & or < in them |
| 17:03 | amalloy | jweiss: (a) reference for claim re cdata/whitespace interaction? all i can find says that cdata just prevvents interpretation of & and < |
| 17:03 | amalloy | (b) like i said, i *believe* data.xml escapes those for you if necessary; have you tried and found that it doesn't? |
| 17:04 | jweiss | amalloy: i could be wrong about the whitespace thing. my example doesn't have those characters in it, let me try |
| 17:05 | jweiss | amalloy: it does escape them using < etc |
| 17:05 | jweiss | still, i still maintain the proper thing to do here is not to have the xml parser parsing these stacktraces, which is what cdata is for |
| 17:06 | amalloy | *nod* that's probably best, although doesn't seem very high-importance to me |
| 17:08 | jweiss | amalloy: yeah, i would guess many people who want to parse/emit xml don't need it |
| 17:08 | amalloy | jweiss: if a feature/todo list existed, cdata would be high on it |
| 17:12 | zilti | I get a "java.lang.ClassNotFoundException: clojure.string" in my REPL when trying to use clojure.string/split, why that? |
| 17:13 | gfredericks | anybody here on ubuntu 11.10 and knows how to alt-tab between same-app windows? |
| 17:13 | gfredericks | zilti: maybe you have to require it? |
| 17:13 | amalloy | zilti: (require 'clojure.string) |
| 17:18 | zilti | amalloy: I tried that. Gives me a "classnotfound" as well |
| 17:18 | amalloy | you forgot the ' probably |
| 17:19 | zilti | amalloy: No, I didn't |
| 17:19 | zilti | Oh wait, no, require gives me nil |
| 17:21 | zilti | Well ok it works now. No way to directly access something in another namespace without "require"? |
| 17:22 | amalloy | you can't run code what ain't been loaded |
| 17:23 | joegallo | the way i think of it is that require says "load this file and make it available in memory as a namespace" |
| 17:23 | joegallo | so, no, you can't reference a namespace without at least requiring it, because there wouldn't be anything to reference |
| 17:26 | zilti | joegallo: Still too much java/scala in my head :) |
| 17:27 | joegallo | no worries, it takes a while to get the pieces to fit such that it seems natural |
| 17:41 | patchwork | hey all, trying to use this geocoding library with lein: http://clojars.org/geocoder-clj |
| 17:41 | patchwork | works fine normally, except when I run lein tasks with it? |
| 17:41 | patchwork | I get this: "Exception in thread "main" java.lang.IllegalArgumentException: Unable to resolve classname: :dynamic (maxmind.clj:34)" |
| 17:42 | patchwork | It is defining the variable fine it seems (since it works normally) |
| 17:42 | patchwork | (def ^:dynamic *service* |
| 17:42 | technomancy | patchwork: looks like it's meant for clojure 1.3 |
| 17:42 | patchwork | but this fails when required inside a lein task? |
| 17:42 | patchwork | Yeah, I am using 1.3 |
| 17:42 | patchwork | :dependencies [[org.clojure/clojure "1.3.0"] |
| 17:42 | technomancy | lein uses 1.2 |
| 17:43 | technomancy | for its own process |
| 17:43 | patchwork | Oh |
| 17:43 | patchwork | : ( |
| 17:43 | patchwork | So how do I use this from inside lein then? |
| 17:43 | patchwork | are you saying there is no way? |
| 17:43 | technomancy | you would have to port the library to 1.2 |
| 17:43 | patchwork | Any path to using lein with 1.3? |
| 17:44 | patchwork | the rest of my app uses 1.3 successfully, it is great |
| 17:44 | technomancy | it's a pretty long-term goal; there are a lot of other changes going into leiningen 2.0 |
| 17:44 | patchwork | crazy |
| 17:44 | technomancy | and we can't upgrade to clojure 1.3 in leiningen 1.x since it would break compatibility with nearly every plugin |
| 17:45 | patchwork | Hmm, I had a little pain converting but it was not such a big deal overall |
| 17:45 | patchwork | I'm using all kinds of libraries too |
| 17:45 | patchwork | this is… unfortunate |
| 17:46 | technomancy | yeah, but breaking plugins in a 1.x release would be really bad form |
| 17:46 | patchwork | what plugins would be broken? |
| 17:46 | technomancy | at the very least, anything that uses contrib and binding |
| 17:46 | technomancy | which probably covers a good 50% |
| 17:47 | technomancy | it would probably be easy to add 1.2 support to this geocoder though |
| 17:47 | patchwork | I thought the idea was that we would be purging libraries that aren't actively maintaining |
| 17:47 | patchwork | technomancy: it is a small project, what would backporting entail? |
| 17:49 | patchwork | The thing is, then I would have a 1.3 version I'm using in my app, and a 1.2 version I use in lein? |
| 17:49 | technomancy | I think purging unmaintained libs was just for old monolithic contrib |
| 17:49 | technomancy | patchwork: I don't think there are very many situations that would call for a split like that. |
| 17:49 | technomancy | usually it's just a matter of using backwards-compatible syntax |
| 17:49 | technomancy | ^{:dynamic true} instead of ^:dynamic |
| 17:49 | technomancy | etc |
| 17:50 | technomancy | and of course ensuring monolithic contrib isn't used |
| 17:51 | patchwork | I have the repo linked in my checkouts dir (to make some edits), but it doesn't seem to be using that one for lein tasks |
| 17:51 | patchwork | is that right? |
| 17:51 | technomancy | yeah, leiningen's own classpath cannot use checkouts |
| 17:51 | patchwork | I tried to correct the issue but it keeps repeating the same error on the same line number (even though the line numbers have changed) |
| 17:51 | technomancy | since it has to be calculated from the bin/lein shell script |
| 17:51 | patchwork | Aha |
| 17:52 | technomancy | annoying but unavoidable |
| 18:18 | amalloy | man, every time i try to use (symbol ns name), i'm astonished to find that neither of the args can be symbols |
| 18:27 | llasram | Huh. That is pretty weird. |
| 18:33 | srid | ,(sort #(compare (:foo %) (:foo %2)) [{:foo 3} {:foo 2}]) ;; is there a better way to write this? |
| 18:33 | clojurebot | ({:foo 2} {:foo 3}) |
| 18:33 | brehaut | ,(sort-by :foo [{:foo 3} {:foo 2}]) |
| 18:33 | clojurebot | ({:foo 2} {:foo 3}) |
| 18:33 | srid | hah, nice |
| 18:33 | jampart | having trouble with ns syntax (:use & :exclude, in particular) but can't seem to find a language spec for clojure. Anyone know where it lives? |
| 18:35 | brehaut | jampart: (doc use) |
| 18:37 | technomancy | clojurebot: ns? |
| 18:37 | clojurebot | ns is unfortunately more complicated than it needs to be, but http://blog.8thlight.com/articles/2010/12/6/clojure-libs-and-namespaces-require-use-import-and-ns may be helpful. |
| 18:38 | technomancy | jampart: that URL has a pretty good tutorial behind it. the docs are pretty poor in that regard. |
| 18:39 | jampart | technomancy: thanks, I'll peruse it later. |
| 18:47 | patchwork | whenever I try to run cake (osx 10.6.7, java 1.6, ruby 1.9.2), I get this error: |
| 18:47 | patchwork | [cake] connection to jvm is taking a long time... |
| 18:48 | patchwork | [cake] you can use ^C to abort and use 'cake kill' or 'cake kill -9' to force the jvm to restart |
| 18:48 | patchwork | But no jvm is running? |
| 18:48 | patchwork | is there further setup I need to do? |
| 18:48 | amalloy | ninjudd: ^ |
| 18:52 | ninjudd | patchwork: i'm in the middle of something right now, but i can help you in a bit. or you may want to ask in #flatland and see if anyone else can help you right now |
| 18:53 | patchwork | ninjudd: okay, thanks |
| 19:09 | technomancy | it's cute how jira thinks I need to be reminded via email that I posted a comment. |
| 19:09 | technomancy | wait, did I say cute. that's not what I meant. |
| 19:10 | hiredman | :) |
| 19:16 | technomancy | seancorfield: I snuck in a little bonus that lets you specify on the CLI which DBs you want to test against: TEST_DBS=mysql,postgres mvn test |
| 19:16 | seancorfield | nice! |
| 19:17 | technomancy | plus readme instructions because I ALWAYS screw up "sudo -u postgres createdb" etc. |
| 19:18 | technomancy | I suspect half the reason nosql is so popular is just that the out-of-the-box dev experience for mysql and postgres is pretty crappy. |
| 19:18 | seancorfield | mysql's experience is good IMO but i agree on postgresql |
| 19:19 | amalloy | yeah, with no db experience at all i didn't find mysql that intimidating, but pgsql is so far inscrutable |
| 19:20 | brehaut | ive never successfully set up postgres without becoming filled with rage first |
| 19:20 | brehaut | but mysql is simple |
| 19:21 | S11001001 | sqlite is simpler, use that |
| 19:21 | brehaut | S11001001: it still has SQL though |
| 19:22 | technomancy | yeah, when I was doing ruby I always chose sqlite for that reason |
| 19:22 | technomancy | no setup nonsense; once it's installed you're good to go |
| 19:24 | patchwork | I love postgres |
| 19:24 | patchwork | after mysql it is a dream |
| 19:25 | brehaut | patchwork: you can love postgres and hate its setup process |
| 19:25 | patchwork | built in recursive queries? table inheritance? awesome |
| 19:25 | technomancy | brehaut: exactly =) |
| 19:25 | patchwork | brehaut: True |
| 19:25 | patchwork | the cost of flexibility I suppose |
| 19:26 | patchwork | though most flexibility I never use |
| 19:26 | brehaut | careful there, anything that you interact with via SQL is inherently not flexible :P |
| 19:26 | patchwork | ha! |
| 19:26 | brehaut | i think you mean less inflexible |
| 19:29 | patchwork | what does everyone have against sql? I used to dog on it too, until I learned how to use it ; ) |
| 19:30 | S11001001 | live on the edge, set up a caching system and use it as your database |
| 19:30 | brehaut | patchwork: not a fan of compositon? |
| 19:30 | S11001001 | if it gets expired you probably didn't need it anyway |
| 19:30 | S11001001 | honestly, if your rows started disappearing occasionally, would you even notice? |
| 19:30 | patchwork | brehaut: how does sql limit composition? sincerely curious |
| 19:31 | patchwork | subqueries are pretty compositional |
| 19:31 | brehaut | patchwork: the constituent pieces of the query cant be named and reused |
| 19:31 | patchwork | brehaut: Aha, yes of course |
| 19:31 | patchwork | that is why I use clojure : ) |
| 19:31 | patchwork | I see what you mean now |
| 19:32 | patchwork | but, you can write sql functions |
| 19:32 | patchwork | not that I do that |
| 19:40 | duck1123 | Does anyone know what causes this error when I do a deps after cleaning? https://gist.github.com/1294201 |
| 19:41 | S11001001 | duck1123: did you do the clean and deps in the same lein command? |
| 19:42 | duck1123 | I get it both ways |
| 19:42 | duck1123 | A second deps will fix it, it's just annoying |
| 19:43 | duck1123 | no lein clean, deps, test, cuke, install for me. |
| 19:43 | duck1123 | more realistically, no lein test! |
| 19:47 | hiredman | duck1123: are you running from a lein checkout? |
| 19:47 | duck1123 | Leiningen 1.6.1.1 on Java 1.6.0_26 Java HotSpot(TM) 64-Bit Server VM |
| 19:48 | hiredman | right, but are you running lein from a git checkout? |
| 19:48 | hiredman | (if you are you may need to fetch deps for lein) |
| 19:48 | duck1123 | I had checked out lein, but I don't think I'm using it |
| 19:49 | duck1123 | let me try anyway |
| 19:49 | amalloy | how can i type-hint an expression? instead of (let [^String x (identity "test")] (.length x)) i'd like to be able to do (.length ^String (identity "test")). i think i know why it doesn't work but i don't know the solution |
| 19:51 | S11001001 | amalloy: going through walk or syntax-quote? |
| 19:52 | dnolen | amalloy: from what I understand the problem is the expression is getting type-hinted and not the return value. |
| 19:53 | hiredman | actually I think that should work |
| 19:53 | amalloy | dnolen: right, that's my understanding also. i thought there was a way around it but i guess if there isn't i'll survive |
| 19:53 | dnolen | amalloy: there's no way to make the second case work as far as I know. You have to create a local and type-hint that. |
| 19:53 | amalloy | hiredman: doesn't, though. on 1.2.1 at least |
| 19:53 | sritchie | ,(clojure-version) |
| 19:53 | clojurebot | "1.3.0-master-SNAPSHOT" |
| 19:54 | sritchie | one quick question, guys -- I'm converting some code to 1.3.0 and noticed this |
| 19:54 | sritchie | ,(class (int 10)) |
| 19:54 | clojurebot | java.lang.Long |
| 19:54 | S11001001 | amalloy: tried it locally in 1.2.1; works |
| 19:54 | hiredman | amalloy: works for me |
| 19:54 | duck1123 | is there any way to type hint the contents of a ref, or do I need to hint when I use it? |
| 19:54 | amalloy | really? hm, wonder what i'm doing wrong. thanks, i'll poke it some more |
| 19:54 | S11001001 | sritchie: int and lon don |
| 19:54 | S11001001 | don't do that anymore; they can only really hint |
| 19:55 | sritchie | got it; so I have to use (Integer. 10)? |
| 19:55 | S11001001 | sritchie: even then, not sure how long it would survive; best to use the primitive coercion at the point of java call |
| 19:55 | dnolen | as far as I know expressions can never be type-hinted. Only vars and locals. |
| 19:56 | S11001001 | I've hinted plenty of exprs with success |
| 19:56 | sritchie | S11001001: I guess I'm confused about how to use primitive coercion |
| 19:56 | S11001001 | did it on Wednesday in 1.3 to suppress that try with reflection thing |
| 19:56 | amalloy | dnolen: (fn [x] (.length ^String (identity x))) seems to not issue any reflection warnings |
| 19:56 | S11001001 | sritchie: if you use (int blah) in an arg position for a java method call, it'll try to pick a primitive int method |
| 19:56 | amalloy | and without the hint, it does |
| 19:57 | S11001001 | because the inferred type of (int blah) is int |
| 19:57 | sritchie | got it |
| 19:57 | nathanmarz | that's pretty confusing |
| 19:57 | nathanmarz | is that a bug with int or is that the expected behavior? |
| 19:57 | S11001001 | duck1123: I suggest writing a function to read the ref that is itself hinted with the intended type |
| 19:58 | S11001001 | nathanmarz: by design in 1.3 |
| 19:58 | S11001001 | in combination with the changes so that primitives can cross function boundaries, it eliminates a combinatorial explosion of AFunction methods |
| 19:58 | duck1123 | S11001001: That's probably what I'll end up doing. I was trying to eliminate reflection over the weekend and I use that pattern a lot |
| 20:00 | S11001001 | one of my favorite things |
| 20:00 | S11001001 | ,(str (proxy [Object] [] (toString [] nil))) |
| 20:00 | clojurebot | nil |
| 20:00 | S11001001 | can't trust anything |
| 20:01 | dnolen | amalloy: huh weird, I could have sworn I've seen cases where it doesn't work, wondering why in your earlier case it didn't work. |
| 20:01 | amalloy | dnolen: yeah, i'm about to put together a gist of the broken/working modes |
| 20:03 | amalloy | dnolen, hiredman: https://gist.github.com/1294255 shows what i think should be two equivalent formations of a macro, one with reflection and one without |
| 20:04 | S11001001 | amalloy: meta doesn't survive syntax quote expansion |
| 20:04 | S11001001 | sometimes :) |
| 20:04 | hiredman | right |
| 20:04 | dnolen | amalloy: yeah you can't type-hint in macros like that. |
| 20:04 | amalloy | ah, i think i see what you mean now |
| 20:04 | hiredman | well, it's tricky, depends how syntax quote decides to mangle it |
| 20:05 | amalloy | because syntax-quote constructs new lists, so the hints on lists might not survive |
| 20:05 | amalloy | but a hint on a non-list happens to stick around |
| 20:05 | S11001001 | I think it's because of the ~ in the list |
| 20:05 | S11001001 | might be constant if no unquote inside the list |
| 20:05 | amalloy | that's vicious |
| 20:06 | S11001001 | have done ~(vary-meta for that |
| 20:06 | hiredman | syntax quote is rather nasty |
| 20:06 | S11001001 | clojure.walk also unfortunately blows it all away |
| 20:06 | dnolen | (with-meta … {:tag 'Traversal}) |
| 20:06 | amalloy | right |
| 20:07 | dnolen | I never tag any other way in a macro, it's too hard to sort out. |
| 20:07 | hiredman | well, 'Traverasl will cause the classname to be resolved in the namespace where the macro is expanded |
| 20:07 | amalloy | hiredman: is anyone interested in your impl of syntax-quote? seems nicer to have it in clojure than in the reader |
| 20:07 | hiredman | amalloy: not interest has been expressed, but I haven't been pushing it |
| 20:07 | dnolen | hiredman: yes, I meant to write out the full namespace, but don't know what it is in this case. |
| 20:08 | amalloy | dnolen: i think his point is `Traversal would work |
| 20:08 | hiredman | or just Traversal |
| 20:08 | S11001001 | or hint the traversal function |
| 20:09 | amalloy | hiredman: interesting. that would result in a tag that's a Class rather than a Symbol; are the two interchangeable in this context? |
| 20:09 | dnolen | hiredman: It seems like I've run into weird cases with using just Traversal. |
| 20:09 | hiredman | interesting |
| 20:09 | hiredman | I certainly thought they were interchangable |
| 20:17 | cemerick | Yes, it needs to be a symbol; classes don't work (or, never have for me, at any rate). |
| 20:17 | hiredman | Oh, yes |
| 20:17 | S11001001 | or string with fully qualified name |
| 20:17 | cemerick | right |
| 20:17 | dnolen | cemerick: classes do work … sometimes |
| 20:17 | dnolen | S11001001: yup |
| 20:18 | cemerick | dnolen: that's strange |
| 20:18 | cemerick | "sometimes" — any idea of the conditions? |
| 20:18 | amalloy | i still seem to be having trouble. as far as i can tell i've succeeded in getting the meta onto the list the macro generates, but i still get this reflection warning: https://gist.github.com/1294255 |
| 20:18 | hiredman | https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L6874 |
| 20:19 | amalloy | at this point it's easier to just go back to hinting a symbol instead, but my understanding of metadata in macros could really use some improvement |
| 20:20 | S11001001 | amalloy: can the traversal function not be hinted? |
| 20:21 | amalloy | S11001001: this is code i'm maintaining, not writing from scratch, and tbh i can't even tell where traversal is defined |
| 20:21 | S11001001 | hee |
| 20:22 | amalloy | there are no bare :use clauses, and it's not anywhere in this file. i'm baffled as to where it could be defined, really |
| 20:22 | dnolen | hiredman: gotcha, mistaken about using the class then. ah macros ... |
| 20:23 | S11001001 | (meta #'traversal) ? |
| 20:23 | amalloy | S11001001: ah. there's a macro in this file defining it |
| 20:23 | hiredman | dnolen: I dunno, no guarantee that is the only path |
| 20:24 | hiredman | :( |
| 20:25 | amalloy | thanks for the nudge S11001001. it wouldn't be practical to hint it, as it's autogenerated from a record definition |
| 20:25 | S11001001 | you could always (def ^Traversal fancy-shmancy-traversal traversal) :) |
| 20:25 | amalloy | heh |
| 20:27 | amalloy | i could probably change the generate-accessors-from-record macro to accept a map of return-value hints though |
| 20:28 | nathanmarz | so, still confused about this int/long stuff |
| 20:28 | nathanmarz | ,(class (Integer/parseInt "1")) |
| 20:28 | clojurebot | java.lang.Long |
| 20:28 | S11001001 | nathanmarz: class is a clojure function, so it has a method that takes primitive long instead of Object |
| 20:28 | hiredman | no |
| 20:29 | amalloy | no, way wrong. it takes an Object, and ints are boxed into Longs |
| 20:29 | hiredman | class is a clojure function, and takes arguments as Objects, so ints have to be boxed, clojure 1.3 boxes ints as Long |
| 20:29 | nathanmarz | ,(.getClass (Integer/parseInt "1")) |
| 20:29 | clojurebot | java.lang.Long |
| 20:29 | nathanmarz | ok |
| 20:29 | hiredman | .getClass is a method on an object |
| 20:29 | nathanmarz | so clojure changes all ints to longs, even from java call? |
| 20:30 | hiredman | (Integer/parseInt "1") returns a primitive long |
| 20:30 | hiredman | in order to call a method on it, it must be boxed |
| 20:30 | amalloy | hiredman: primitive int, which is boxed into a Long, you mean? |
| 20:30 | hiredman | right |
| 20:30 | nathanmarz | this is new behavior in 1.3 |
| 20:30 | S11001001 | ,(class (Integer/valueOf "42")) |
| 20:30 | clojurebot | java.lang.Integer |
| 20:30 | amalloy | nathanmarz: yeah |
| 20:30 | nathanmarz | hm |
| 20:31 | nathanmarz | what's difference between valueOf and parseInt? |
| 20:31 | danlarkin | ,(version) |
| 20:31 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: version in this context, compiling:(NO_SOURCE_PATH:0)> |
| 20:31 | danlarkin | ,(clojure-version) |
| 20:31 | clojurebot | "1.3.0-master-SNAPSHOT" |
| 20:31 | S11001001 | valueOf returns Integer, parseInt returns int |
| 20:31 | nathanmarz | i see |
| 20:31 | S11001001 | (similar for all of those classes) |
| 20:31 | Raynes | God willing, lazybot will be on 1.3 soon. |
| 20:31 | nathanmarz | i have to say i really disagree with that behavior |
| 20:32 | danlarkin | nathanmarz: get in line |
| 20:37 | chouser | there's a giant ponderous thread on the google group that led to this behavior |
| 20:38 | amalloy | more than one, right? |
| 20:38 | danlarkin | chouser: why do you always have to be so reasonable |
| 20:39 | dnolen | nathanmarz: if you want to get a primitive int / Integer you always can. But from 1.3.0 stand point int / Integer is for interop now. |
| 20:41 | dnolen | chouser: heh, the behavior was decided upon, the thread is simply the ponder bike-shedding. |
| 20:41 | dnolen | ponderous |
| 20:42 | chouser | hm, I suppose you're right. |
| 20:42 | chouser | danlarkin: I can be grouchy and unreasonable. Shall we talk about classpaths? |
| 20:42 | danlarkin | I'm in favor! |
| 20:42 | hiredman | (of all the classes having a path) |
| 21:01 | jstrate | Hi, I need to add the \q |
| 21:47 | kd4joa | does anyone know if the midje test framework works with clojure 1.3? specifically I'm having trouble with the lein-midje plugin |
| 21:48 | jodaro | haven't tried it yet |
| 21:51 | duck1123 | kd4joa: get the new version it works now |
| 21:54 | kd4joa | thanks. where do I get it from though? I'm just specifying lein-midje "1.0.0" in my dev-dependencies |
| 22:08 | BruceBGordon | newbiie emacs-starter-kit, what version should I install? the stable version from http://emacs.naquadah.org/, and then apt-get install emacs? |
| 22:13 | duck1123 | I'm not sure what the latest lein-midje is, but you want 1.3-alpha4 for midje |
| 22:14 | kd4joa | yeah I think I got it. thanks. it looks like it's 1.0.4 |
| 22:14 | kd4joa | it's working now. thanks! |
| 22:14 | kd4joa | you don't happen to use midje-mode in emacs too, do you? |
| 22:14 | kd4joa | I'm having a problem with that too |
| 22:15 | duck1123 | I didn't really like it |
| 22:15 | kd4joa | ok thanks. it's nice to be able to run the tests from the emacs buffer with the tests |
| 22:15 | duck1123 | I had it working once, but I just wrap everything in a deftest, so it wasn't working very well |
| 22:16 | duck1123 | clojure-test-mode still works if you do it that way |
| 22:17 | kd4joa | thanks. I'm pretty new to clojure and haven't tried that yet. I like the way midje specifies the tests |
| 22:17 | amalloy | kd4joa: i was pretty miffed at midje-mode because it uses keybindings that are supposed to be reserved for personal use |
| 22:18 | kd4joa | I get so baffled by the inconsistencies between use, require, import, :use, :require, :import that I spend so much time just trying to get my environment setup |
| 22:20 | duck1123 | there's still too much of an element of style with ns forms. It fits in with Clojure's philosophy, but it also makes my OCD tick when dealing with libs that use their ns form differently |
| 22:20 | duck1123 | I'm talking about using () vs [] |
| 22:21 | amalloy | duck1123: those aren't always interchangeable, which is the worst part |
| 22:21 | kd4joa | oh yeah. some take a vector, some can take a vector of vectors, some want a list, etc, etc. frankly it's baffling. |
| 22:22 | amalloy | i've finally settled down into a style that is easy to understand, and everyone else's style is terrible :P |
| 22:22 | duck1123 | I try to stick to (:usc (clojure.core [incubator :only (-?>)])) |
| 22:22 | duck1123 | er, :use |
| 22:23 | duck1123 | parens for namespace prefixes, braces for the inner part, and parens for the inner lists |
| 22:24 | amalloy | duck1123: i think vectors for the inner lists are definitely better |
| 22:24 | duck1123 | I've yet to see a definitive style guide to say I'm doing it wrong, and it's hard to tell by looking at other code |
| 22:24 | amalloy | (foo bar baz) implies foo is special, and emacs indents accordingly if you need to span lines. [foo bar baz] puts them all on equal footing |
| 22:24 | duck1123 | so (clojure.core [incubator :only [-?>]]) |
| 22:25 | duck1123 | I think I did that at one time, but I saw more people doing () |
| 22:26 | amalloy | yeah. then there are the folks who don't like prefix lists. i think they're not wrong, but it's sad to have to type stuff more than once |
| 22:27 | duck1123 | I go back and forth on them, but lately I've been pro. I also have many namespaces that'll all share a common prefix |
| 22:29 | duck1123 | I'm trying to get better about my naked uses, but sometimes it's hard not to |
| 22:29 | amalloy | ~guards |
| 22:29 | clojurebot | SEIZE HIM! |
| 22:29 | amalloy | many sins may be forgiven...but naked :use sends you straight to hell |
| 22:30 | duck1123 | I've been making it a point to go back through and fix all my ns forms |
| 22:31 | amalloy | duck1123: tried slamhound? |
| 22:31 | duck1123 | This is my nastiest ns form by far https://github.com/duck1123/jiksnu/blob/master/src/jiksnu/routes.clj |
| 22:31 | duck1123 | I've played with it, but need to get it working right |
| 22:31 | amalloy | yeah, it won't work on this ns form. wouldn't work on mine either, so i don't use it |
| 22:34 | amalloy | anyway rather than look at that code for one more second i'm heading outta here |
| 22:34 | duck1123 | aww... it's not that bad is it? |
| 22:34 | duck1123 | later |
| 22:34 | konr | if I have two mutually-calling functions such as "(defn a [n] (if (= n 1) 1 (b (dec n)))) (defn b [n] (+ (a n) n))", what can I do to make evaluate? Define their names before their definitions? |
| 22:34 | amalloy | i'll be back with more mock-criticism later |
| 22:34 | S11001001 | konr: yes, (declare b) before the defn a |
| 22:35 | jcromartie | duck1123: holy living crap on a stick attacking Tokyo |
| 22:35 | jcromartie | t |
| 22:35 | jcromartie | ha |
| 22:35 | konr | S11001001: thanks! |
| 22:35 | jcromartie | that's one heck of a ns |
| 22:37 | duck1123 | I plan on moving some of it out and use my definitialize macro to load the views/filters/triggers later |
| 22:38 | duck1123 | It's been hell juggling the namespaces to avoid circular deps |