2009-12-24
| 00:00 | fanatico | as well as the comments on fogus's blog. |
| 00:00 | tomoj | I don't understand why it's complaining about bytes... I'm not even using it :( |
| 00:00 | devlinsf | Ah |
| 00:02 | devlinsf | chouser: ping |
| 00:11 | aking | tomoj: clojure 1.1 has a new defn for bytes - you'll need to remove it from agent. |
| 00:11 | devlinsf | aking: good catch! |
| 00:15 | tomoj | aking: ooh! thanks |
| 00:16 | aking | probably not remove it from http/agent.clj but rename it - doesn't look to do the same thing as core's bytes |
| 00:17 | tomoj | I guess http.agent should be updated |
| 00:20 | tomoj | hmm.. not sure how to get leiningen to use my patched contrib |
| 00:23 | hiredman | swing is truely a torture devised to destroy me |
| 00:24 | devlinsf | hiredman: sometimes I wonder if Gosling gets paid a nickel every time a developer swears |
| 00:25 | liebke` | hiredman: what are you building with Swing? |
| 00:25 | hiredman | I'm rewriting my repl |
| 00:26 | aking | tomoj: I'd suggest just overwritting the existing control jav under lib - seems to work for me (don't run 'lein deps' though) |
| 00:26 | aking | contrib* |
| 00:26 | liebke` | ah, excellent. I'm really interested in having a gui repl. I hope your luck with Swing improves :-) |
| 00:26 | hiredman | the stuff I was doing to scroll the scrollpane down to the bottom in the previous iteration does not seem to work now |
| 00:27 | hiredman | http://www.thelastcitadel.com/images/Screenshot-Clojure.png |
| 00:27 | hiredman | from the previous iteration |
| 00:27 | devlinsf | hiredman: Why not use a JTextArea? |
| 00:27 | hiredman | because I want to render arbitrary stuff |
| 00:27 | devlinsf | Or JPanel *in* the scroll pane |
| 00:28 | hiredman | I do have a JPanel in the scrollpane |
| 00:28 | devlinsf | Let JScrollPane do the work |
| 00:28 | liebke` | very cool! inline images, that would be awesome for Incanter |
| 00:28 | hiredman | devlinsf: jscrollpane does no work |
| 00:28 | devlinsf | And are you just adding labels? |
| 00:28 | hiredman | no |
| 00:28 | devlinsf | How come? |
| 00:28 | hiredman | I have a jscrollpane |
| 00:28 | hiredman | in it is a jpanel |
| 00:29 | devlinsf | Right |
| 00:29 | hiredman | to this jpanel I am adding arbitrary jcomponents |
| 00:29 | devlinsf | And it's not working? |
| 00:29 | devlinsf | Hmm... |
| 00:29 | hiredman | and I have the layout for the jpanel set to flowlayout |
| 00:29 | hiredman | wait |
| 00:29 | hiredman | no, box layout? |
| 00:29 | hiredman | anyway it lays stuff out downwards |
| 00:29 | devlinsf | Right |
| 00:29 | hiredman | and the scrollpane does scroll |
| 00:30 | devlinsf | Hmmm... |
| 00:30 | hiredman | but the keyword, in my description which you seem to have missed is: autoscroll |
| 00:30 | devlinsf | Like any other REPL |
| 00:31 | hiredman | previously I was getting the visibleRect and then using scrollToVisibleRect on the viewport |
| 00:31 | hiredman | but it doesn't apear to work now |
| 00:32 | devlinsf | Okay, you've got me |
| 00:32 | devlinsf | Stupid swing |
| 00:33 | devlinsf | If I understand you correctly, you've tried manipulating the JViewport? |
| 00:34 | devlinsf | Hmmm... I know I've set the viewport manually before |
| 00:34 | aking | tomoj: which dependency are you using for clojure-contrib in your project.clj file? The latest contrib already has a fix in for it |
| 00:34 | devlinsf | If I find the code, I'll let you know |
| 00:34 | devlinsf | *set programatically |
| 00:34 | hiredman | devlinsf: I have too, and it worked last time, but now it doesn't |
| 00:34 | devlinsf | Huh |
| 00:35 | devlinsf | Wierd |
| 00:35 | hiredman | :| |
| 00:35 | devlinsf | have you set it in Clojure before? |
| 00:36 | devlinsf | My experience was in normal Java |
| 00:36 | hiredman | this was in clojure |
| 00:36 | hiredman | I have the code right here |
| 00:36 | hiredman | it's like a page up in my editor |
| 00:36 | devlinsf | No f'ing clue, man |
| 00:37 | devlinsf | Reset the REPL? Stranger things have worked |
| 00:40 | tomoj | aking: oh, great |
| 00:40 | tomoj | I guess |
| 00:40 | tomoj | I guess I just need to update, then |
| 00:41 | tomoj | is [org.clojure/clojure-contrib "1.0-SNAPSHOT"] right? |
| 00:41 | aking | tomoj: I'm using: [org.clojure/clojure-contrib "1.1.0-master-SNAPSHOT"] |
| 00:42 | tomoj | thanks |
| 00:45 | tomoj | hmm.. seems like that didn't fix it :( |
| 00:47 | aking | tomoj: try 'lein clean' and 'lein deps' - maybe it's still picking up the old one? |
| 00:49 | tomoj | aking: ah, my fault, I had my manually installed jars dumped in there too |
| 00:49 | tomoj | aking: works now, thanks for your help |
| 00:50 | aking | tomoj: np - I'm still just learning leiningen too :) |
| 00:51 | lucidrains | > If i have had no exposure to functional programming before, should i first jump into clojure or start with haskell? |
| 00:51 | tomoj | any lisp exposure? |
| 00:52 | lucidrains | nope |
| 00:52 | lucidrains | is Lisp like the grandfather of all these languages? |
| 00:53 | tomoj | eh, I dunno |
| 00:54 | tomoj | clojure seems like less of a brainfuck to me, but I already was comfortable with lisp |
| 00:54 | tomoj | don't need to worry about types as much, but that might not be a good thing either :) |
| 00:58 | mitchellh | Whats the difference between "sync" and "dosync" ? I see that "sync" has flags TBD but what would be the purpose of using it in code now vs. dosync? |
| 00:59 | tomoj | I think it's just there for future use |
| 01:00 | mitchellh | Alrighty |
| 01:00 | hiredman | use dosync |
| 01:05 | mitchellh | hiredman: Any specific reasoning other than avoiding the TBD? |
| 01:08 | hiredman | because it's not used |
| 01:08 | hiredman | sync is a primitive and provides some room for future use, but no one uses it |
| 01:09 | hiredman | 2009:Nov:17:03:44:57 rhickey : prefer dosync for now |
| 01:09 | mitchellh | hiredman: Thanks, I was only poking about it because I'm reading rich's ant.clj file and he used "sync" everywhere |
| 01:10 | tomoj | that was before dosync existed I guess |
| 01:12 | mitchellh | Figured |
| 01:12 | mitchellh | Just was making sure :) |
| 01:21 | hiredman | I think I am closing in on the issue |
| 01:25 | KirinDave | Ugh, so you can't use netty without a java class? |
| 01:26 | KirinDave | For annotations? I mean you really simply cannot |
| 03:38 | maacl | Why does lein fail to download clojure-1.1.0-alpha-SNAPSHOT.jar ? |
| 03:43 | timothypratley | "alpha" is now "master" I think |
| 04:04 | notostraca | yes! I got counterclockwise to create working executable jars! |
| 04:05 | notostraca | the only caveat is that every library the app uses must be in the same folder |
| 04:05 | notostraca | (as the jar) |
| 04:06 | notostraca | i was working at it so long that I don't know if i can reproduce the steps though |
| 04:37 | G0SUB | what should be the right type hint for a java fn that takes Collection<String> ? |
| 04:41 | hiredman | G0SUB: #^Collection |
| 04:41 | G0SUB | hiredman: figured that out just now. many thanks. |
| 04:55 | bOR_ | Trying to figure out how I can change the settings of the slime-connect called jvm (mainly -Xmx). While i'm looking, does anyone in here know the solution? |
| 05:02 | vy | bOR_: See slime-lisp-implementations variable. |
| 05:03 | vy | C-h v slime-lisp-implementations |
| 05:03 | bOR_ | thanks :). |
| 05:08 | bOR_ | (swank-clojure-extra-vm-args '("-server" "-Xmx1024M")) |
| 05:10 | bOR_ | hmm. but putting that in my .emacs won't make much sense if I start my swank using leiningen. |
| 05:12 | bOR_ | I'll solve that problem later. |
| 05:12 | vy | bOR_: You told SLIME, not leniningen. SLIME configuration will only affect the vms fired up by SLIME. For lenininininingen,... I have no idea. |
| 05:13 | bOR_ | misunderstanding there then. You still connect to the leiningen swank from within emacs using M-x slime-connect. |
| 05:13 | bOR_ | thanks for the pointer though :). |
| 09:51 | saml | hey, how can I get documentation of reader macro? |
| 09:51 | saml | (doc ') is error |
| 09:51 | clojurebot | Unmatched delimiter: ) |
| 09:54 | hoeck | saml: http://clojure.org/reader |
| 09:54 | saml | so no way to do it in the repl |
| 09:54 | saml | ah user cannot define reader macro anyways! |
| 09:55 | hoeck | saml: you may try sth like backquote and see into what the reader macro expands to |
| 09:56 | saml | (~') |
| 09:56 | hoeck | saml: but often those are special forms, documented only on the clojure page |
| 09:56 | hoeck | ,`'a |
| 09:56 | clojurebot | (quote sandbox/a) |
| 09:57 | saml | coolz thanks hoeck |
| 10:34 | hamza | guys, if a java call requires 2 variables, and i have a vector of [val1 val2] is there a shorter way to call the function besides, (.call obj (first vec) (second vec))? |
| 10:55 | saml | hey can emacs do auto completion? what's the keyboard shortcut (using Clojure Box on windows) |
| 10:56 | saml | i can press TAB to get auto completion in repl. but i'm not sure if that's possible in editor |
| 11:00 | Hun | saml: M-Tab |
| 11:00 | Hun | if your window manager eats the M, use Escape Tab |
| 11:00 | saml | Hun, yah but when I do Alt-Tab, window manager eats it |
| 11:00 | Hun | ;) |
| 11:00 | saml | Escape-Tab minimizes the window |
| 11:01 | Hun | then try C-M-i |
| 11:01 | saml | oh escape-tab works |
| 11:01 | saml | haha awkward key combo i should get used to |
| 11:01 | saml | C-h k will tell me what command it is. and i can remap! |
| 11:02 | Hun | yep |
| 11:03 | Hun | try M-x customize-variable slime-complete-symbol-function |
| 11:03 | Hun | in CL i use compound, which is awesome - you can complete mvb => multiple-value-bind |
| 11:04 | saml | that did not let me set key binding. i should google it |
| 11:05 | saml | does emacs have word completion? not related to clojure but using whatever is written in the buffer |
| 11:05 | hamza | yes M-. will complete anything.. |
| 11:05 | Hun | that can be done with hippie-expand |
| 11:06 | Hun | i bind that to M-/ |
| 11:06 | Hun | it can complete pretty much anything, using heuristics. it searches through buffers, filesystems, dictionarys, ... |
| 11:07 | saml | oh C-c Tab is already slime-complete-symbol |
| 11:08 | saml | wow M-/ works |
| 11:11 | jburd | Try using the auto-complete.el package from the emacswiki. You won't ever need to hit M-/ again. |
| 11:12 | saml | too much to learn! |
| 11:25 | saml | ,``'a |
| 11:25 | clojurebot | (clojure.core/seq (clojure.core/concat (clojure.core/list (quote quote)) (clojure.core/list (quote sandbox/a)))) |
| 11:25 | saml | wheeeeeeeee |
| 11:28 | spariev__ | hi, anyone using enclojure ? is there any keybinding to quickly switch from editor to project repl ? |
| 11:37 | saml | ,(defn foo [{x #(:x %1)}] (println "Hello" x)) (foo {:x "u"}) |
| 11:37 | clojurebot | DENIED |
| 11:40 | saml | ,(let [{x #(:x %1)} {:x "u"}] (println "Hello" x)) |
| 11:40 | clojurebot | Hello nil |
| 11:40 | saml | why can't i do that? |
| 11:42 | the-kenny | ,(let [x #(:x %1) {:x "u"}] (println "Hello" x)) |
| 11:42 | clojurebot | java.lang.IllegalArgumentException: let requires an even number of forms in binding vector |
| 11:42 | the-kenny | oops |
| 11:49 | jweiss | in the ns macro, :import section, anyone know how to import from the default package? |
| 11:49 | jweiss | just putting the classname doesn't work, it thinks that's the pkg name |
| 11:50 | the-kenny | jweiss: What's the "default package"? |
| 11:51 | jweiss | the-kenny: one at the toplevel, with no package name |
| 11:51 | the-kenny | jweiss: hm.. I'd look how the generated .class is named.. but isn't using the default package discouraged? |
| 11:52 | jweiss | the-kenny: yes. but i'm using a password hashing lib that is just one class, and they didn't put it in a package |
| 11:52 | jweiss | so rather than rebuilding it i was just gonna try to import it as-is |
| 11:52 | the-kenny | jweiss: Found in Google: "You can’t use classes in the default package from a named package." |
| 11:52 | jweiss | the-kenny: the class is just BCrypt.class |
| 11:53 | jweiss | the-kenny: what does that mean "from a named package" |
| 11:53 | the-kenny | jweiss: From any other package than the default one |
| 11:53 | jweiss | the-kenny: but i'm calling it from clojure. clojure doesn't have packages |
| 11:53 | the-kenny | (In clojure for example user, clojure.contrib.seq-utils etc. etc) |
| 11:54 | jweiss | oh, namespace == package? |
| 11:54 | jweiss | did not know that... |
| 11:54 | the-kenny | hm.. I think so |
| 11:54 | the-kenny | I'm not absolutely sure |
| 11:54 | jweiss | bah, i guess i'm just gonna repackage it, will just take a minute and i gotta restart slime, but whateva |
| 11:54 | jweiss | thanks |
| 11:54 | saml | spariev__, i just installed netbeans. go to Tools->Options->Keymap (tab) and search for repl |
| 11:55 | saml | find Netbeans IDE Repl under Window category |
| 11:55 | saml | assign shortcut Ctrl+Alt+0 |
| 11:55 | saml | Ctrl+0 goes to editor |
| 12:00 | spariev__ | saml, thanks, I missed that. Actually, I' using Project Repl with my classpath, and there are no shortcuts for it. well, at least I can switch back to editor faster now |
| 12:01 | saml | no idea :P |
| 12:25 | srirampc | ? |
| 12:33 | fliebel | What could possibly be wrong with this line? It's giving java.lang.IllegalArgumentException: Key must be integer: (writer (map #(template % @pages (first args) (second args)) @pages)) |
| 13:08 | joshua-choi | A question. I have a sequence "s". To get the first element in it that does not fulfill a function "pred", I do (first (drop-while pred s)). How, then, can I best get the element *right before* that one? |
| 13:09 | saml | split the list at first pred. and get the last element of the first list? |
| 13:11 | fliebel | Maybe reduce is better for this |
| 13:11 | joshua-choi | Well, split uses filter. Unfortunately, I need to get the element right before the *first* element that doesn't fulfill the predicate, so using filter or split doesn't work |
| 13:11 | joshua-choi | I think |
| 13:11 | fliebel | With reduce you can return the next item until the next item is true and the return the other |
| 13:11 | joshua-choi | fliebel: How might you use reduce? |
| 13:11 | joshua-choi | Yeah |
| 13:12 | fliebel | one moment.... |
| 13:12 | joshua-choi | That would work, but it would always go through the entire sequence |
| 13:13 | joshua-choi | Using drop-while in (first (drop-while pred s)) stops the sequence immediately when the proper element is found, since drop-while is lazy |
| 13:13 | joshua-choi | It'd be great if there was a similar way for getting the element before that first element |
| 13:13 | fliebel | (reduce #(if %2 %1 %2) [false false true false]) |
| 13:14 | joshua-choi | ,(reduce #(if %2 %1 %2) [false false true false]) |
| 13:14 | clojurebot | false |
| 13:15 | fliebel | (reduce irc://irc.freenode.net/#(if (= :c %2) %1 %2) [:a :b :c :d]) |
| 13:15 | fliebel | ,(reduce irc://irc.freenode.net/#(if (= :c %2) %1 %2) [:a :b :c :d]) |
| 13:15 | clojurebot | java.lang.ClassNotFoundException: irc://irc.freenode.net |
| 13:16 | joshua-choi | Is there a way, though, that doesn't have to go through the whole sequences? The sequences I'm dealing with are going to be very large |
| 13:16 | fliebel | I don't know, I'm not a Clojure expert, you see... |
| 13:16 | saml | how do you zip two lists? |
| 13:17 | saml | (1 2 3) ==> ((1 2) (2 3)) |
| 13:17 | fliebel | I'm — without success so far — trying to solve an very unhelpful java error. |
| 13:17 | saml | zip the list with its tail and modify pred |
| 13:17 | saml | to test second element of the list |
| 13:18 | saml | if you find it, then first element of the list is previous element |
| 13:21 | fliebel | How can I find out where an error comes from? |
| 13:21 | fliebel | (generator.clj:0) is obviously not right... |
| 13:28 | chouser | ,(some (fn [[a b]] (when (odd? b) a)) (partition 2 1 [2 4 6 8 9 10 11]))) |
| 13:28 | clojurebot | 8 |
| 13:29 | chouser | joshua-choi: that's for you |
| 13:29 | joshua-choi | Excellent |
| 13:29 | chouser | saml: pretty much your idea. 'partition' as a sort of pre-packaged zip-with-tail |
| 13:30 | chouser | fliebel: does generator.clj start with an 'ns' form? |
| 13:30 | fliebel | chouser: yes |
| 13:30 | fliebel | chouser: but nothing changed with that since it stopped working |
| 13:30 | chouser | that's usually what the :0 indicates. Haven't tried to figure out why. |
| 13:31 | fliebel | chouser: strange, but I actually think I found out which line it is by removing stuff… |
| 13:32 | chouser | yeah. :-/ |
| 13:32 | aravind | hi, I need some help getting slime to work.. I am using the latest git versions of clojure-mode and swank-clojure, when I start slimme, the repl starts okay, but slime can't talk to it and fails with "Error in timer" slime-attempt-connection... |
| 13:32 | fliebel | chouser: Any idea what "java.lang.IllegalArgumentException: Key must be integer" might mean in a for expression? |
| 13:33 | mitchellh | aravind: I'll show you my .emacs with the setup and maybe that'll help |
| 13:33 | aravind | mitchellh: cool! |
| 13:34 | mitchellh | aravind: https://gist.github.com/7f060cbd1879927e3538 |
| 13:34 | mitchellh | aravind: Thats everything that makes it work for me, you should be able to glean from the paths how everything is laid out |
| 13:34 | mitchellh | aravind: With that, i simply do M-x slime and it works |
| 13:35 | chouser | fliebel: trying do a lookup in a vector with a non-integer |
| 13:35 | aravind | mitchellh: okay, let me try that setup. |
| 13:37 | fliebel | chouser: I'm looking at some functions now… but without helpful error reporting it's not easy... |
| 13:39 | aravind | mitchellh: did you checkout the latest slime from github as well? |
| 13:39 | aravind | mitchellh: I am using the one that comes with emacs |
| 13:39 | aravind | oh :( |
| 13:43 | mattrepl | aravind: slime changes fairly quickly, it's best to grab the latest |
| 13:46 | fliebel | Is future suitable for doing io? |
| 13:46 | aravind | mattrepl: I would.. but there is a big fat warning that the latest slime may not work with clojure, since its designed more for CLs |
| 13:47 | mattrepl | aravind: where at? |
| 13:47 | aravind | mattrepl: http://groups.google.com/group/clojure/browse_thread/thread/4960adce009d4760/b1b259efc229cad0?lnk=gst&q=swank+2009+dec#b1b259efc229cad0 |
| 13:48 | aravind | I wish something like this would be simpler.. |
| 13:49 | mitchellh | aravind: Um… no, from CVS |
| 13:49 | mitchellh | aravind: cvs -d :pserver:anonymous:anonymous@common-lisp.net:/project/slime/cvsroot co slime |
| 13:49 | mitchellh | aravind: straight into my emacs.d includes folder |
| 13:49 | mattrepl | aravind: ah, ok. yes that does happen sometimes. |
| 13:49 | mattrepl | ELPA is a good suggestion |
| 13:50 | aravind | I have never used that, so no clue how elpa works.. |
| 13:50 | mattrepl | the link technomancy provided has installation instructions: http://tromey.com/elpa/ |
| 13:51 | aravind | mattrepl: yeah, I am reading about it now.. a lot of folks seem to recommend it |
| 13:52 | mattrepl | I had been managing my own packages for awhile and was reluctant to move from "good enough" to elpa - but it does work and streamlines package management |
| 13:53 | aravind | mattrepl: yeah, my concern exactly.. I am in the habit of just getting whatever .el files are needed and sticking them in a directory. |
| 13:54 | mattrepl | be ready to spend a few moments cleaning out any old packages once you've re-installed them with ELPA, but that's straightforward |
| 14:05 | aravind | mattrepl: okay, I installed clojure-mode, swank-clojure and slime with the elpa thingie and I still get the same error I did when I started out. |
| 14:05 | mattrepl | did you remove previous versions? |
| 14:05 | aravind | which makes me suspect that something upstream is broken. |
| 14:05 | aravind | mattrepl: I did. |
| 14:06 | mattrepl | hmm, anything interesting in *inferior-lisp* buffer? if so, please pastebin or msg |
| 14:08 | JonSmith | sorry,what is the error? |
| 14:08 | aravind | mattrepl: http://pastebin.com/d193f5732 and I get a backtrace with this - http://pastebin.com/d44bdf41e |
| 14:13 | aravind | you guys think its still my env thats screwy? |
| 14:14 | mattrepl | not sure, was googling around a bit for anything related, nothing helpful turning up |
| 14:15 | mattrepl | ooc, what emacs version and OS? |
| 14:16 | aravind | mattrepl: 23.1.1 and debian |
| 14:20 | JonSmith | hmm i'm using emacs 22 |
| 14:20 | JonSmith | idk if that matters |
| 14:21 | aravind | well.. at least now I know the problem wasn't with my original setup. |
| 14:22 | ieure | Is there some way to make my code dump me into SLDB when I’m using slime/swank-clojure? |
| 14:23 | ieure | It isn’t throwing an exception, but it’s not working and I want to step through to figure out why. |
| 14:26 | joshua-choi | What's the difference between repeat and replicate, other than repeat's n parameter defaulting to infinity? |
| 14:27 | devlinsf | joshua-choi: I think replicate is going to be deprecated |
| 14:27 | devlinsf | joshua-choi: Not 100% sure, though |
| 14:28 | joshua-choi | Hmm, I see |
| 14:44 | olerixmann | hi |
| 14:44 | olerixmann | on christmas eve |
| 14:45 | olerixmann | i have a problem gettinge resources from a jar file... |
| 14:45 | olerixmann | maybe someone can give me a hint why i always get zero pointer-exceptions |
| 14:45 | olerixmann | i try it this way: |
| 14:46 | olerixmann | (with-in-str (slurp (.. 'this (getClass) (getResource (str "templates/" schtring)))) (read)) |
| 14:46 | olerixmann | schtring is a string |
| 14:48 | JonSmith | did you try printing out the different arguments to the repl and seeing which one is nil? |
| 14:48 | JonSmith | my guess would be it has something to do with 'this, but really is hard to tell |
| 14:48 | shoover`` | aravind: Any chance your machine has really tight security such that you couldn't even connect to a socket on a localhost port? |
| 14:48 | aravind | shoover``: hmmm.. :) thats possible |
| 14:49 | aravind | I didn't think of that.. but yeah, let me check |
| 14:49 | shoover`` | aravind: because the one paste says swank opened the socket, but the phrase "Connection refused" is in your debugger paste |
| 14:50 | olerixmann | getResource returns nil |
| 14:50 | olerixmann | .. |
| 14:50 | aravind | shoover``: phew okay.. no that wasn't it. |
| 14:51 | aravind | shoover``: I disabled my firewall and still same error. |
| 14:51 | aravind | I would have felt really stupid if that was the problem! |
| 14:52 | olerixmann | maybe someone has an example of loading anything from the application jar? |
| 14:54 | JonSmith | hum |
| 14:55 | JonSmith | the thing is it should really be the same as doing it from java |
| 14:55 | JonSmith | it might be a placement issue |
| 14:55 | JonSmith | http://www.velocityreviews.com/forums/t134544-load-images-and-text-file-from-jar-file.html |
| 14:56 | olerixmann | thx |
| 14:56 | JonSmith | if you are getting an error it might be useful to do (.printStackTrace *e) |
| 14:58 | olerixmann | its just the zero pointer except from the getResource, but i'm trying with leading slash now :) |
| 14:59 | hiredman | olerixmann: null point |
| 14:59 | hiredman | er |
| 14:59 | JonSmith | yeah, hopefully it will be the same as the java problem |
| 15:00 | hiredman | using with-in-str and read and slurp is horrible |
| 15:00 | hiredman | (binding [*in* some-reader] (read)) |
| 15:03 | olerixmann | reading this way works |
| 15:03 | hiredman | but is is horrible |
| 15:03 | olerixmann | yeah, maybe |
| 15:03 | olerixmann | i have some other problems ;) |
| 15:04 | hiredman | well, if you code in that style I am not surprised |
| 15:05 | olerixmann | i don't think its so ugly |
| 15:05 | olerixmann | what is the with-in-str macro for? |
| 15:05 | olerixmann | if not for this |
| 15:05 | olerixmann | sorry, my english is not as good as i want it to be |
| 15:05 | hiredman | the ugliness is from reading the whole file into memory as a string |
| 15:06 | olerixmann | ok |
| 15:06 | olerixmann | its just a few lines |
| 15:06 | olerixmann | not that bad |
| 15:06 | hiredman | it's a bad habit |
| 15:06 | hiredman | smells of php |
| 15:07 | olerixmann | ;) |
| 15:07 | olerixmann | no php on my side |
| 15:10 | olerixmann | seems to work now, thanks |
| 15:10 | shoover`` | aravind: I don't know what else to check, but there's definitely a networking issue. Either that socket isn't really open or you can't get to it. That's why that "connection refused" is there |
| 15:10 | hiredman | what you want to do is someting like (with-open [o (-> (ClassLoader/getSystemClassLoader) (.getResouceAsStream "Whatever") InputStreamReader. PushbackReader. BufferedReader.)] (binding [*in* o] (read))) |
| 15:11 | olerixmann | but i always get strange errors when compiling, but it works anyways.... |
| 15:11 | hiredman | duck streams should take care of all those readers |
| 15:11 | olerixmann | ok, thanks |
| 15:11 | olerixmann | i'll change that |
| 15:11 | aravind | shoover``: yeah.. you are probably right. |
| 15:11 | aravind | shoover``: I am trying to go down to the elisp stuff thats connecting and checking if that works. |
| 15:12 | aravind | shoover``: thanks for looking into it though. |
| 15:16 | shoover`` | aravind: here's some test code you can try: http://paste.bighugh.com/scratch.html |
| 15:17 | shoover`` | (thanks, technomancy, scpaste rules) |
| 15:17 | hiredman | what about the java side? |
| 15:17 | hiredman | does the jvm start and is it listening? |
| 15:23 | aravind | hiredman: yeah, the java side is up and listening |
| 15:24 | aravind | although, it quits listening once you connect to it and quit (from telnet) |
| 15:31 | aravind | shoover``: that test code isn't working on my box.. |
| 15:32 | aravind | a plain telnet to that port works, but within emacs it fails. |
| 15:33 | aravind | shoover``: fails with '(file-error "make client process failed" "Connection refused" :name "crino" :buffer "crino" :host "127.0.0.1" :service 8888)' |
| 15:34 | shoover`` | aravind: I dunno, something's hamstringing your emacs |
| 15:36 | q2 | Any tips on an efficient case-insensitive lookup by key against a map? |
| 15:37 | q2 | given: {"Foo" "bar"} lookup "foo" ==> "bar" |
| 15:38 | LauJensen | (filter #(= (tolower x) (tolower y))) is probably near-optimal |
| 15:41 | q2 | lau: thanks. what lib is tolower in? |
| 15:41 | LauJensen | ,(.toLower "HI THERE") |
| 15:41 | clojurebot | java.lang.IllegalArgumentException: No matching field found: toLower for class java.lang.String |
| 15:41 | LauJensen | ,(.toLowerCase "HI THERE") |
| 15:41 | clojurebot | "hi there" |
| 15:41 | q2 | ah java's. got it. |
| 15:41 | LauJensen | ah.. :) |
| 15:50 | q2 | lau: so close! a lowercase method that doesn't bomb on null would be more awesome :) |
| 15:51 | LauJensen | Can you write an example of what you want/what u have? |
| 15:51 | q2 | lowercase what comes out of a regex prior to the map lookup. regex can return NIL |
| 15:51 | q2 | so (. toLowerCase nil) --> bad |
| 15:54 | LauJensen | (filter #(when-let [match (re-seq #"...")] (= (.toLowerCase match) (.toLowerCase %)))... |
| 15:54 | LauJensen | So that kind of thing? |
| 15:55 | q2 | yeah that's the basic idea |
| 15:55 | LauJensen | That will work then |
| 16:05 | aravind | I think I figured it out.. |
| 16:05 | aravind | shoover``: it appears that my latest kernel updates (and/or clojure updates) enabled and started using ipv6 on my box. |
| 16:06 | aravind | and the clojure repl (created by slime) was listening on a ipv6 port, but slime connection was trying to talk to the ipv4 address. |
| 16:06 | aravind | disabled ipv6, and stuff seems to be working correctly now. |
| 16:06 | aravind | what a waste of time! |
| 16:06 | q2 | lau: thanks. you are right. the key difference was when-let vs just let :) |
| 16:11 | q2 | one last silly REPL question. how to abort the query I'm writing without a ctrl c or ctrl d -- which exits the repl |
| 16:33 | LauJensen | You mean if you've started a lengthy computation and you want to abort halfway through, still keeping the REPL? |
| 16:33 | q2 | yup |
| 16:33 | LauJensen | Sorry I dont think thats possible |
| 16:34 | q2 | ah, that's a shame. |
| 16:34 | chouser | repl-utils add-break-thread! |
| 16:34 | LauJensen | ~source add-break-thread! |
| 16:34 | q2 | excellent! |
| 16:35 | LauJensen | q2, sorry about that bit of bad advice |
| 16:35 | chouser | well, using add-break-thread! is techincally bad advice -- uses deprecated Java features. |
| 16:35 | chouser | on the other hand, it generally works. so ... |
| 16:36 | q2 | no worries. i'm still very much a novice, excuse the silly questions. |
| 16:37 | q2 | thanks chouser. that works quite well. |
| 17:10 | somnium | can lein be used to compile .java? |
| 17:12 | LauJensen | Is there a definitive paper on Write Skew lying around somewhere ? |
| 17:14 | chouser | wikipedia has an article. might have useful links too, if it's content is insufficient. |
| 17:15 | arohner | ,(deftype my-type [foo bar]) |
| 17:15 | clojurebot | DENIED |
| 17:15 | arohner | nice |
| 17:16 | somnium | chouser: have you looked at the javascript-compiler it that new google closure thing? |
| 17:16 | arohner | anyways, it appears you can't use merge on deftypes |
| 17:17 | LauJensen | thanks chouser I'll have a look again, I only found a small reference on the snapshot iso page |
| 17:17 | arohner | even if they implement IPersistentMap |
| 17:17 | somnium | arohner: if you include IPersistentMap in interfaces you can use conj |
| 17:17 | arohner | lisppaste8: url |
| 17:17 | lisppaste8 | To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste. |
| 17:17 | somnium | some of the other fns seem to rely on associative/collection |
| 17:18 | arohner | merge uses conj, and it's still not working for me |
| 17:18 | arohner | one sec, I'll paste this |
| 17:19 | somnium | arohner: what error? and try (conj atype [:foo :bar]) |
| 17:19 | lisppaste8 | arohner pasted "merge deftypes?" at http://paste.lisp.org/display/92600 |
| 17:20 | arohner | assoc works, conj does not |
| 17:21 | somnium | arohner: really, I had the opposite last time I tried |
| 17:21 | somnium | I guess the edge is bleeding, so Ill stop talking :) |
| 17:22 | liebke | somnium: there is a javac plugin for lein: http://github.com/antoniogarrote/lein-javac |
| 17:23 | somnium | liebke: great! thanks |
| 17:24 | arohner | hmm, (conj (Foo 1 2) [:c 3]) works |
| 17:40 | chouser | somnium: I'm aware of its existence, but I haven't really looked at it. |
| 17:42 | somnium | chouser: it turned the gensym mess created by my still-broken compiler into frighteningly readable javascript. It might be interesting to try it on clojurescript. |
| 18:10 | chouser | somnium: interesting. I wasn't expecting it to generate *readable* js. |
| 18:13 | somnium | chouser: for locals it assigns vars like a b c, I was unrolling function calls for arg evaluation and getting big nests of curly braces and var ..., it cut out all the redundancy |
| 18:14 | somnium | chouser: seems like a big win if any clojure->js project can worry only about semantics and let google's optimizer do the rest |
| 18:15 | chouser | yes, I agree |
| 18:25 | q2 | any tips on returning the hierarchy for any given classs? |
| 18:25 | q2 | all interfaces / classes it implements / inherits |
| 18:27 | somnium | ,(ancestors String) |
| 18:27 | clojurebot | #{java.lang.Object java.lang.Comparable java.io.Serializable :clojure.contrib.generic/any java.lang.CharSequence} |
| 18:28 | q2 | thanks |
| 18:59 | sdeobald | Am I blind or is there no way to specify an output directory to clojure.lang.Compile? |
| 19:04 | mikehinchey | sdeobald: *compile-path* |
| 19:04 | sdeobald | mikehinchey: |
| 19:04 | sdeobald | thanks! |
| 19:13 | sdeobald | mikehinchey: Hmm. I'm not quite sure how to apply that to the Java world when doing this: `java -Dclojure.compile.path=src -cp lib/clojure.jar:src clojure.lang.Compile' |
| 19:14 | sdeobald | Or should I be using lein or something these days for compiling and creating jars? |
| 19:15 | dliebke | I recommend lein (or mvn) |
| 19:32 | ieure | Hm. So if I have a Java instance in an atom… How do I use that? Do I have to let-bind it? |
| 19:32 | hiredman | :( |
| 19:32 | ieure | e.g. I was doing (.writeBytes stream) |
| 19:32 | hiredman | you have to deref the atom |
| 19:32 | ieure | But put that in a map in an atom, then changed it to (.writeBytes (:stream @atom-obj)) |
| 19:32 | ieure | But that gives me: No matching method found: writeBytes for class clojure.lang.Atom |
| 19:33 | hiredman | you must have the stream wrapped in an atom too |
| 19:33 | ieure | hiredman, I know, just wondering if I have to deref it in a let-binding before trying to call the method, or if there’s a better way, or if I’m doing it wrong. |
| 19:33 | hiredman | (atom {:stream (atom some-stream)}) |
| 19:33 | hiredman | or something |
| 19:33 | ieure | No. |
| 19:34 | hiredman | ieure: that is what the exception says you have |
| 19:35 | hiredman | the exception says the result of (:stream @atom-obj) is an atom |
| 19:35 | hiredman | and since atom-obj is an atom, that means you have nested atoms |
| 19:37 | ieure | Okay - I see what I did. |
| 19:37 | ieure | Thanks. |
| 19:58 | q2 | mmm (try (catch)) is killing performance. there something faster than (try) ? |
| 19:58 | q2 | i don't care what exception it is. i just want to do an alternative. |
| 20:00 | slashus2 | Killing performance? |
| 20:01 | q2 | yeah. consider this: (defn missing?3 [x] (try (empty? x) (catch Exception _ (nil? x)))) |
| 20:01 | q2 | that above line is 3800 times slower than |
| 20:02 | q2 | this line here: (defn missing?4 [x] (or (and (or (coll? x) (seq? x) (string? x)) (empty? x)) (nil? x))) |
| 20:02 | q2 | the idea is for (missing?) to take any param and tell you if its NULL or empty |
| 20:02 | q2 | er nil |
| 20:03 | q2 | so "" () {} [] nil all eval to true |
| 20:03 | q2 | maybe it's just best to check for each of those cases, but heh. |
| 20:03 | q2 | the overhead with try catch is still clear. |
| 20:04 | KirinDave | q2: It's slower even if you don't hit the exception case? |
| 20:04 | q2 | yes |
| 20:05 | q2 | actually mayb enot. |
| 20:05 | q2 | but in this case I expect 50% of the calls to throw the exception |
| 20:05 | q2 | be nice to have an alternate to (try (catch)) that simple stops the exception from generating, replacing it with an expr. |
| 20:06 | q2 | guess it's java limitation? |
| 20:06 | KirinDave | q2: This just in: exceptions are expensive. :) |
| 20:07 | KirinDave | q2: Does (or (nil? x) (empty? x)) work? |
| 20:07 | q2 | i know :) it would be nice to have a mode that turns off exceptions for certain calls :) so rather than generate one, do X |
| 20:07 | q2 | no |
| 20:07 | q2 | because empty? generates an exception |
| 20:08 | q2 | if you pass it an integer |
| 20:08 | KirinDave | So yeah it's your second example. |
| 20:08 | KirinDave | I'm surprised empty? lets that happen, tbh. It should say false for ints. |
| 20:08 | q2 | options are: rewrite missing?, rewrite empty? |
| 20:08 | q2 | yeah it shouldn't not intuitive that way |
| 20:08 | KirinDave | Well... |
| 20:09 | q2 | or ask the irc about other exception handling tricks! |
| 20:09 | KirinDave | I'd profile a multiple dispatch version. |
| 20:09 | q2 | i did |
| 20:09 | KirinDave | How much slower was that? |
| 20:09 | q2 | it is slower than the second option |
| 20:09 | KirinDave | Huh. Well then what's wrong with the first? ;) |
| 20:09 | q2 | and results in 3 defmultis hehe |
| 20:10 | q2 | i don't like it because it's still pretty slow |
| 20:10 | q2 | php is beating me out |
| 20:10 | q2 | lol |
| 20:10 | KirinDave | (defn missing? [x] (or (and (or (coll? x) (seq? x) (string? x)) (empty? x)) (nil? x))) |
| 20:10 | KirinDave | ? |
| 20:10 | q2 | that's the fastest one |
| 20:10 | KirinDave | Yeah. What's wrong with that besides the order in which you call it? |
| 20:10 | q2 | takes over 1 second to do 9M calls |
| 20:11 | q2 | the same in something slow like PHP, takes about 0.7 seconds |
| 20:11 | KirinDave | Um, so? |
| 20:11 | q2 | i switchd to clojure for speed :) |
| 20:11 | q2 | for this particular task |
| 20:11 | q2 | oh well |
| 20:11 | KirinDave | There is always the maybe-m monad |
| 20:11 | q2 | this is the one bottleneck in the application that is slower. but i'll continue working on it. |
| 20:12 | q2 | i should check that out. the problem seems simple enough though. |
| 20:12 | KirinDave | You could basically eliminate any cases where nil enters the chain. |
| 20:13 | KirinDave | And the constructions used in clojure are fairly fast, esp for the maybe-m monad. |
| 20:14 | KirinDave | q2: also, if speed is _really_ important on this |
| 20:15 | KirinDave | q2: You've written your fastest version in the slowest possible way. Write it to short circuit earlier. |
| 20:15 | q2 | yeah reworking the cases is an option. or not using empty? maybe, but writing my own. looks like empty just calls: (not (seq x)) |
| 20:15 | KirinDave | (and (not (nil? x)) ...) |
| 20:15 | q2 | right. i don't understand the use case yet. but i think nil? and empty? cases are about 50/50 |
| 20:16 | KirinDave | If that's the case, then inverting the form of the logic will get you big benefits. |
| 20:16 | q2 | and i'm too lazy to figure each case hehe |
| 20:16 | KirinDave | But seriously |
| 20:16 | KirinDave | if factoring out nils in a chain of operations is a big deal, that's pretty much exactly what the maybe-m is for. |
| 20:16 | KirinDave | ANd it's just function calls, it will be fast. |
| 20:17 | q2 | i like that notion. time to learn monads... |
| 20:17 | KirinDave | There are 2 great tutorials I've been wrestling with. |
| 20:17 | q2 | Neat. Got links? |
| 20:17 | KirinDave | For me, it's not easy. |
| 20:17 | KirinDave | http://intensivesystems.net/tutorials.html is for one set |
| 20:17 | KirinDave | (That work on compojure is epic) |
| 20:18 | KirinDave | And the other one: http://onclojure.com/2009/03/05/a-monad-tutorial-for-clojure-programmers-part-1/ |
| 20:18 | q2 | Thanks Kirin. |
| 20:19 | KirinDave | I'm trying to see if I can use the state monad to use nio to make a faster server-socket library, myself. |
| 20:19 | KirinDave | The current server-socket doesn't scale very well. |
| 20:19 | q2 | I'll share the monad when I get around to it. If it turns out to be the best. |
| 20:19 | KirinDave | Sure. |
| 20:19 | KirinDave | Good luck. |
| 20:19 | q2 | Good luck to you too. |
| 20:32 | Luyt | I'm still trying to understand the concept of monads. Maybe that these tutorials will help ;-) |
| 20:45 | srirampc | ? |
| 21:08 | pdk | would a clojure struct be more lightweight with its memory footprint than a java object when using both for value semantics for the same things |
| 21:08 | pdk | e.g. if i had a Point class in java to store a 3d coordinate as three doubles and i did the same with a clojure struct, could i expect a smaller memory footprint and perhaps cleaner code with the struct |
| 21:12 | hiredman | pdk: Point will be more light weight |
| 21:12 | hiredman | but it is not immutable :| |
| 21:13 | hiredman | datatypes (from the new branch) should be the same or less |
| 21:13 | pdk | hm is there information on clojure memory consumption for these sorts of details |
| 21:13 | pdk | i mean i know it's nitpicking and with persistency you gotta get used to it but :p |
| 21:19 | hiredman | pdk: best to run your code through some kind of profiler |
| 21:19 | q1 | hired: what profiler would you recommend? |
| 21:19 | pdk | i assume that most profilers like jhat would work with clojure code after compiling it to class files and still produce useful results without much extra fuss? |
| 21:21 | hiredman | rhickey has mentioned yourkit |
| 21:21 | pdk | hm google turned up a blog post on jvisualm + clojure q1 |
| 21:21 | hiredman | yourkit costs money (but there is an evaluation copy) |
| 21:23 | hiredman | I've yet to be in a situation where I needed to profile |
| 21:23 | pdk | hmm |
| 21:23 | pdk | q1 jhat is bundled with the jdk and according to this blog post jvisualm is as well with more recent versions |
| 21:23 | pdk | soooo time to update jdk! |
| 21:25 | hiredman | good idea, I've seen reports of pretty significat speed ups just from switching to a newer jvm |
| 21:27 | pdk | still jdk 6 here at least but hey |
| 21:27 | hiredman | yeah |
| 21:28 | hiredman | 5 -> 6 |
| 21:32 | pdk | what is the windows kernel installation of the jre supposed to be |
| 21:32 | hiredman | erm |
| 21:32 | hiredman | I don't think the windows "kernel" has a jre |
| 21:34 | pdk | on the jre download page from java.sun.com it lists a "windows kernel installation" download, not sure what that's about |
| 21:35 | pdk | certainly the obvious meaning of kernel here seems odd |
| 21:38 | hiredman | http://java.sun.com/javase/6/docs/technotes/guides/jweb/otherFeatures/jre_install.html#kernel |
| 21:56 | pdk | gah |
| 21:57 | pdk | what's the right way to uninstall your old version of the jre/jdk again after update |
| 21:59 | tomoj | anybody noticed lein-swank not putting src/ on the classpath? |
| 22:44 | konr | anybody using both clojure and CL on Emacs? Will I run into trouble trying to install them? |
| 22:48 | tolstoy | konr: I doubt it. You can always just try it and see. ;) |
| 22:48 | tolstoy | konr: I start up swank by hand and use M-x slime-connect, which pretty much solves all the classpath issues for me. |
| 22:49 | tolstoy | I just make a little shell script that builds the classpath and starts swank. |
| 22:49 | tolstoy | Seems like slime's smart enough to know which system it's attaching to. |
| 22:50 | tomoj | konr: here's my old config https://gist.github.com/a59bdb809b378b7f1da1 |
| 22:50 | tomoj | dunno if it will help |
| 22:51 | konr | tomoj, tolstoy: thanks, guys! I'm gonna play with it :) |