#clojure log - Jul 04 2011

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:00 hugod: next release of pallet will have image downloading for vbox built in

0:00 no, pallet has its own interface to vbox api

0:00 technomancy: cool

0:00 I've got to say, the features of vagrant have really won me over the past few weeks

0:01 hugod: we have a computeservice abstraction that gets used to talk to jclouds, vbox, or a node list

0:01 technomancy: having your VM environment be just another file that's checked in is a big win for repeatability

0:01 ihodes: xiaolongxia: i think you'd be able to show him some practical applications using racket pretty quickly-they've got some great stuff going on. otherwise, i'd point him to stewart's Programming Clojure, and keep an eye on things that are out of date. i still think that's the best book for a beginner.

0:01 hugod: technomancy: yes, definitely

0:02 cemerick: technomancy: see, here I was idly thinking of creating yet another build tool, and you're out there showing me why that's just not a healthy life choice ;-)

0:02 ihodes: building is horrible. horrible. horrible. (still emotional over a week of time spent recovering from usign SVN 1.4, an insane ant build, and a 3mil line codebase) :(

0:05 technomancy: cemerick: yeah, I, uh... I try to lead by example.

0:05 "eat your veggies, boys, or you will turn out like technomancy"

0:07 hugod: cemerick: any particular features you were idly planning?

0:07 cemerick: It's a cautionary tale, to be sure. I've mostly tried to stay away from bikeshed domains, just to avoid the mental anguish it would seem to entail.

0:10 hugod: I've just been taking notes here and there about things various tools get right, and others different tools get wrong, etc. I'm wondering if it's worth trying to find a global maxima, at least for my fanbase.

0:10 That population being me, of course.

0:10 :-P

0:10 amalloy: hugod: https://github.com/pallet/ritz links to a 404 version of slime.el

0:10 hugod: amalloy oops, thanks

0:12 cemerick: ihodes: sorry, missed your msg; 3m LOC?

0:12 My condolences.

0:13 hugod: amalloy: should be fixed

0:15 amalloy: hugod: thanks. apparently i had to completely rip apart my emacs config to start using marmalade so i could have a crack at ritz. it's an adventure so far

0:15 hugod: amalloy: I try and put of the faint of heart in the readme

0:15 technomancy: amalloy: fwiw emacs 24 is fairly painless

0:15 plus you can write elisp with lexical scope!

0:16 which I know you've always wanted

0:16 amalloy: technomancy: i switched my office machine from 24 to 23 a week or so ago

0:16 technomancy: oy

0:16 amalloy: i *could not* figure out how to get 24 to stop creating new windows and frames of ridiculous sizes every time something wanted to open in a different window

0:17 technomancy: weird

0:17 the only things I know that try to create new frames are ediff and speedbar

0:17 the former which is easy to disable, the latter which is best avoided

0:17 amalloy: technomancy: i was getting new frames for completion buffers

0:18 all i got from #emacs was the usual "bleeding edge is your problem"

0:18 technomancy: wow, crazy

0:18 in cocoa?

0:18 amalloy: lucid

0:19 technomancy: madness

0:19 amalloy: actually natty, i guess

0:24 hugod: you mention cake in the Install section, implying it's supported, but i don't see how to launch ritz with cake

0:26 technomancy: is resolve supposed to work with nested classes?

0:26 amalloy: technomancy: eh?

0:27 technomancy: (resolve 'org.apache.lucene.util.Version/LUCENE_30) ; => nil

0:27 amalloy: technomancy: try $ instead of /?

0:27 hiredman: ^-

0:27 technomancy: err... I guess it's a field

0:27 never mind

0:28 how do you dynamically determine whether a class has a given field?

0:28 hiredman: having resolve work on fields is an interesting idea

0:28 reflection

0:28 * technomancy doesn't know anything about java; don't tell anyone

0:29 hiredman: I can lend you my java reflection in action book

0:29 technomancy: hiredman: right, because I don't care about the difference

0:29 (def *version* (try (eval 'org.apache.lucene.util.Version/LUCENE_30)

0:29 (catch Exception _

0:29 org.apache.lucene.util.Version/LUCENE_29)))

0:29 dang it

0:30 mispaste, but you get the idea. it's icky.

0:30 amalloy: &(-> String .getFields seq)

0:30 sexpbot: ⟹ (#<Field public static final java.util.Comparator java.lang.String.CASE_INSENSITIVE_ORDER>)

0:30 amalloy: technomancy: there's a named .getField, i'm fairly sure

0:31 hiredman: there is a wallhack-field function somewhere in contrib

0:31 amalloy: but all you need should be available in the javadoc for java.lang.Class

0:31 technomancy: amalloy: that's perfect; thanks.

0:31 hiredman: http://richhickey.github.com/clojure-contrib/java-utils-api.html#clojure.contrib.java-utils/wall-hack-field

0:31 for static fields you use nil for obj

0:32 * cemerick just finished writing a detailed HOWTO for using annotations in Clojure for integrating with JAX-RS

0:32 hugod: amalloy: add ritz as a dev dependency, and cake ritz

0:32 * cemerick needs a drink, a pistol, and one bullet

0:33 hugod: cemerick: commiserations, just been doing that for my ritz maven plugin

0:33 amalloy: hugod: no good, but that might be because i'm on an unstable version of cake

0:33 hugod: mm, my version of cake seems very broken

0:34 cemerick: hugod: ritz? I'm behind the times :-(

0:34 amalloy: cemerick: swank-clj's new name

0:34 cemerick: Annotations in Clojure are mostly *bleh*. It's JAX-RS that's absolutely dead-nuts infuriating.

0:34 ah, ok

0:34 nice

0:34 amalloy: yeah, i like the name

0:35 one day, far in the future, when i've resurrected my computer, i hope to like the tool too

0:35 cemerick: It's amazing to me that that's what's considered the web services hotness in Java-land these days.

0:35 hiredman: also the clojure tests fail in annotations tests when run on openjdk7 on osx

0:37 cemerick: I think it's the only place in the book where we have a "don't use this stuff, really" warning.

0:43 * hugod installs ruby 1.9

0:54 hugod: amalloy: I'll have a look at the cake plugin tomorrow when I get cake to run again

0:55 amalloy: hugod: thanks. in the meantime i'll just use lein; cake seems to have a lot of headaches

0:58 hugod: actually it doesn't work with lein either: Exception in thread "main" java.lang.ClassNotFoundException: com.sun.jdi.VirtualMachine (jdi.clj:1)

0:58 i imagine this is because i have openjdk rather than sun/oracle

6:03 lnostdal-laptop: ring seems to mess around with stdout (*out* ?) or something .. debug output using println doesn't show up in slime here

6:04 ..and exceptions end up in the terminal; where i started `lein swank'

6:04 ..is there some way of fixing this? .. i.e. println output should end up in slime, and exceptions also

6:05 hoeck: lnostdal-laptop: the server code runs in a different thread than the slime repl, and slime only redirects stdout of its own repl thread

6:06 lnostdal-laptop: ah, i remember this being an issue with SBCL also .. there was a fix for it though .. hmm

6:07 (setf swank:*globally-redirect-io* t) ;; fixed it for SBCL

6:08 hoeck: for exceptions, you could wrap your handler bodies in (try (do ) catch Exception e (swap! *server-exceptions* conj e)) and then manually throw the last exception or so from the slime repl

6:08 or mess with the default exception handler of the thread the ring handler is invoked in, probably by modifying some server config

6:11 lnostdal-laptop: maybe (System/setOut *out*) works

6:15 lnostdal-laptop: (let [*out* *out*] (defn handler [req] (binding [*out* *out*] ...)))

6:15 seems to work

6:16 ..with regards to output and stuff

6:18 halfprogrammer: lnostdal-laptop: the stacktrace middleware prints the exception in *err* stream

6:18 that is why you see exception in lein repl

6:23 lnostdal-laptop: ok

6:24 i'm not using that middleware though

6:24 halfprogrammer: oh

6:25 lnostdal-laptop: (..should i? .. i'm not sure what that middleware does; i thought it was used to display the stacktrace on the web page; which is not what i'm after..)

6:28 is there a `break' ..for triggering an exception?

6:29 halfprogrammer: lnostdal-laptop: as far as I remember it displays the stacktrace both on the web page and on the *err* stream.

6:30 I am not getting what you mean by `break

6:31 lnostdal-laptop: like http://www.lispworks.com/documentation/HyperSpec/Body/f_break.htm

6:32 halfprogrammer: if you want to insert breakpoints you can use swank.core/break.

6:33 lnostdal-laptop: using this Javaish thing seems to work: (throw (Exception. "I got here"))

6:33 ah

6:33 halfprogrammer: :)

7:45 peteriserins: I want to create a macro that serves as with-connection-to-my-database (with known credentials)

7:46 (defmacro with-connection-to-mydb [db-spec & body] (let [credentials ..] (with-connection ~db-spec ~@body)))

7:46 tried unquoting the let and it didn't work

7:46 *backquoting

7:52 rlb: peteriserins: what are you trying to do? i.e. when should credentials be computed?

7:52 peteriserins: rlb: compile time

7:52 rlb: So what didn't work?

7:53 peteriserins: for starters, I need to have db-spec as a symbol

7:53 and I cannot find how to do that

7:55 rlb: Do you have an example of a form the expansion you'd like?

7:56 peteriserins: (with-c-mydb db (print "Credentials: " db))

7:59 rlb: I actually see now that the db parameter is redundant

7:59 rlb: it should just be [& body]

8:00 rlb: OK.

8:01 peteriserins: rlb: OK, it works now

8:01 rlb: I surrounded everything with #

8:50 gfrlog: if I have a long (millions) seq of numbers, (apply + coll) and (reduce + coll) ought to perform equivalently, right?

9:02 halfprogrammer: gfrlog: should it necessarily be the same?

9:03 gfrlog: well I can't think of why it ought to be different. I only ask because it feels weird to call a function with millions of args.

9:03 halfprogrammer: wont reduce take more time?

9:04 gfrlog: you think + is optimized for lots of args?

9:04 Chousuke: apply + calls reduce so no

9:04 gfrlog: ah yeah, I see that in the source now

9:04 halfprogrammer: hmmm

9:04 gfrlog: ([x y & more] (reduce + (+ x y) more))

9:04 Chousuke: in some cases apply is faster though

9:04 like apply str

9:05 gfrlog: StringBuilder

9:05 halfprogrammer: hmm

9:05 gfrlog: Chousuke: interesting, thanks

9:06 Chousuke: in general, if you expect that a function can do something smart if it controls what to do with more than two args, then use apply.

9:06 otherwise, reduce is fine

9:30 archaic`: hi. anyone out there?, how come in compojure/ring? a route (GET "/" [] (println "foo")) will print foo twice whenever i refresh the browser at uri / ?

10:30 msappler: hi

10:30 i want to share the source code of a clojure game I developed on google code ... what licence is appropriate?

10:49 gfrlog: archaic`: you could use CURL to check if the repetition happens in the app or the browser

10:52 * gfrlog isn't sure why he put curl in all caps

10:53 * gfrlog thinks CURL would be an interesting http verb and wonders what it would mean

11:19 msappler: okay I open sourced my game under MIT: http://resatori.com/open-sourcing-cyber-dungeon-quest

11:33 ejackson: msappler: congrats !

11:35 cemerick: msappler: looks pretty fun — reminds me of gauntlet from my C64 days :-D

11:36 you should put a new video up on the google code page — I had to hunt around for the one you did in March

11:37 msappler: thanks ... just have to find out how to put videos pictures on google code

11:37 cemerick: Or, just a permalink to it on your blog or something *shrug*

11:40 msappler: put the old video there :) https://code.google.com/p/clojure-rpg/

11:42 cemerick: nice; I'll tweet tomorrow when more people are around

12:08 matthias__: ,(doc replicate)

12:08 clojurebot: "([n x]); Returns a lazy seq of n xs."

12:14 pcavs: What's the best way to test reading from standard input with clojure + leiningen?

12:37 matthias__: someone should add a list of the most popular clojars to clojars.org

12:55 fliebel: What is "the best" was of serializing Clojure data structures? Just print and read, or is there something more advanced?

12:55 *way

13:06 rlb: fliebel: if you're just going to/from clojure, I'd think read/write unless you have special needs.

13:06 fliebel: (for clojure s/write/pr/)

13:22 fliebel: rlb: Okay, fine :)

13:26 mids: and if you need performance / compatibility probably thrift or protocol buffers

13:26 fliebel: mids: But then you'd need to specify the format beforehand, right? Or can you just say (thrift ["aa" 3])

13:28 mids: yes

13:28 err, yeah you need to specify the format beforehand

13:28 fliebel: I that case I'd rather use... the ztellman thing.

13:29 gloss

13:30 rlb: and if you need to speak to python, etc., perhaps json...

13:31 mids: or XML :P

13:41 babilen: technomancy: ping

13:47 ilyak: Thing I don't like about Clojure:

13:48 Sometimes it treats java collections as first-class collections. Sometimes it doesn't.

13:48 It's not mentioned in docs and it's painful

13:48 I guess I'll have to roll out some my own collection functions

13:48 ,(contains? (Collections/singleton 1) 1)

13:48 clojurebot: false

13:49 ilyak: This sucks

13:53 gfrlog: that's funny it returns anything

13:53 ,(contains? :foo :bar)

13:53 clojurebot: false

13:53 gfrlog: weerd.

14:25 agumonkey: hi all

14:29 anybody knows why jline fails when moving cursor or deleting/backspacing ?

16:45 amalloy: &(java.util.Collections/singleton 1)

16:45 sexpbot: ⟹ #<SingletonSet [1]>

16:45 amalloy: &(java.util.Collections/singleton (into-array [1]))

16:45 sexpbot: ⟹ #<SingletonSet [[Ljava.lang.Integer;@72fd0e]>

16:45 amalloy: hm. well duh, of course that's not variadic. never mind :P

17:03 pcavs: How does one support default values in a idiomatic, succinct way? Does one have to use multimethods and then pass the default value to the expanded version of the function?

17:06 amalloy: pcavs: your suggested solution doesn't make any sense as far as i can tell. by "multimethod" do you mean "function with multiple arities/bodies"?

17:06 pcavs: yes, sorry

17:06 amalloy: if so, that's one common way to do it

17:06 pcavs: alrighty, what's the other?

17:06 amalloy: another is to use a map and destructure it with the :or key

17:07 &((fn [& {:keys [a b] :or {b 10}}] [a b]) :a 9)

17:07 sexpbot: ⟹ [9 10]

17:23 amalloy: matthias__: btw, i've never used replicate. these days repeat does the same thing in fewer characters; i think replicate was probably written when repeat didn't take an N argument?

17:23 davekong: I am getting the error: Wrong number of args (1) passed to ... for a function that always takes one argument, any ideas what could be going on? I tested it in the repl and I don't get an error but within my program I do

17:24 matthias__: ,(doc repeat)

17:24 clojurebot: "([x] [n x]); Returns a lazy (infinite!, or length n if supplied) sequence of xs."

17:24 amalloy: davekong: is it a macro?

17:24 davekong: amalloy: no

17:26 gfrlog: davekong: is it a function you defined?

17:26 davekong: gfrlog: yes

17:27 The argument I am passing is a map if that is of significance

17:28 gfrlog: shouldn't be. For lack of any other ideas, could you show us the function definition and call?

17:28 davekong: sure

17:31 http://codepad.org/h2RwYCif gfrlog , the call is on the line with the CALLE HERE comment, with-client-socket is a macro

17:38 Somelauw: Has cake, leininingen, emacs or anything an interactive mode? Does clojure-jack-in have a manual which possibly explains it?

17:38 amalloy: emacs is one giant interactive mode

17:39 davekong: fwiw, the (((game :rules) :max-raises) (betting-round game)) construct is confusing to me

17:40 i'd probably write it as a get-in

17:41 davekong: amalloy: okay thanks, I'm I still pretty new to clojure

17:43 amalloy: davekong: i'm not sure if it's a common thing or just my personal preference, but (:foo m) feels a lot more natural to me than (m :foo), though the first only works for keywords

17:43 ibdknox: amalloy: I'm the same way

17:43 amalloy: but i'm afraid i don't see anything in your code that would throw the exception you're seeing

17:43 Somelauw: amalloy: what manual page of emacs should I read to learn about interactive mode?

17:44 amalloy: Somelauw: if you have a version of clojure-mode that has jack-in, you should just be able to call it and it will start up a repl buffer. but ask technomancy, if that doesn't seem to work

17:46 Somelauw: amalloy: that already works. But I have a file with code and want to test the code in that file.

17:46 amalloy: C-c C-k compiles/runs the current file

17:46 Somelauw: So I want to make the functions in that file accesible from the repl.

17:47 amalloy: C-c C-c compiles the top-level form you're currently pointing at; C-x C-e evaluates the form (not necessarily top-level) immediately before point

17:47 there's http://www.pchristensen.com/slimecommands.pdf for a slime cheat sheet - clojure's swank doesn't support all of these yet, but you can try something and hope

17:48 Somelauw: Well thanks. C-k, C-k seems to work. Any good tutorial or reference since I want to learn more?

17:49 Okay, thanks for slime-commands.

17:49 amalloy: i bet technomancy's screencast covers this sort of thing

17:52 Somelauw: Which screencast do you mean?

17:55 amalloy: http://technomancy.us/120 i think. i haven't watched it

17:56 Somelauw: okay, thanks, I will take a look at it

18:05 davekong: amalloy: I figured it out, the wrong number of args was to #(= \r) not the function itself.. that should be #(= \r) or using partial

18:06 amalloy: davekong: good lesson. always paste the stacktrace

18:06 which would be pretty clear in your case

18:07 wrong number of arguments (1) passed to my.game$legal-actions$fn__5786 or something

18:07 rather than: wrong number of arguments (1) passed to my.game$legal-actions

18:07 davekong: amalloy: http://codepad.org/X1iawnyY

18:10 hopefully now that I understand the stack a little better I won't need to ask next time

18:10 stack trace

18:10 amalloy: davekong: in this case the thing that's useful is knowing how clojure creates classnames for functions

18:11 actually i'm not sure why there's no numbers after the $fn in your example. but basically, each closure is named <enclosing-function-name>$fn__nnnn

18:12 eg, ##(class (partial + 5))

18:12 sexpbot: ⟹ clojure.core$partial$fn__3678

18:12 davekong: ##(class #(+ 5))

18:12 sexpbot: ⟹ sandbox10545$eval13084$fn__13085

18:13 davekong: ##(class #(= \r))

18:13 sexpbot: ⟹ sandbox10545$eval13093$fn__13094

18:13 davekong: hmm

18:14 amalloy: davekong: of course learning that you need to include % in the function is a good lesson, but i'd solve your problem by using a set as a function: (filter #{\r} (round-actions game)

18:14 gfrlog: davekong: sorry bout wandering off.

18:15 davekong: np

18:15 amalloy: and you can do the same in the cond expression in play-game: (cond (nil? msg) game, (#{\# \;} (first msg)) (recur game))

18:15 gfrlog: did it get sorted out? lotta stuff to read through...

18:15 amalloy: yeah

18:16 gfrlog: oh I see it was the anon function

18:16 those are fun

18:16 amalloy: gfrlog: today's lesson was for us to always demand a real stacktrace, not a summary

18:17 gfrlog: amalloy: could you repeat that as a stacktrace?

18:17 amalloy: $kill gfrlog

18:17 sexpbot: KILL IT WITH FIRE!

18:17 * gfrlog kilt

18:19 davekong: neat

18:19 * gfrlog knit

18:19 davekong: I like how concise clojure can get

18:20 mrnex2010: What would be a simple way to execute code upon invoking lein repl? (edgar goncalves sais that since lein 1.3 u cant just put it in the project.clj)

18:22 gfrlog: woah

18:22 I was gonna make a joke that you could make a user.clj and just stick your code in there

18:22 then I tried it and it worked

18:23 it worked...twice actually.

18:23 davekong: Well I noticed core.clj gets loaded automatically?

18:23 amalloy: i think user.clj is deprecated though

18:23 gfrlog: probably has something to do with that "server listening..."

18:23 oh does it?

18:23 mrnex2010: da hell? if i have a user.clj in the project, it will execute that code?

18:23 amalloy: or something like that

18:23 gfrlog: mrnex2010: did it for me

18:24 $ lein repl

18:24 USER

18:24 USER

18:24 REPL started; server listening on localhost:27883.

18:24 user=>

18:24 where user.clj contains (println "USER")

18:24 mrnex2010: oh thats nice!!

18:24 gfrlog: lemme def something and see if it's there...

18:25 that works too

18:25 * gfrlog tries core.clj

18:25 amalloy: pft. you wish

18:25 mrnex2010: coz i wanna make something that imports all namespace in the project for developement purposes

18:25 gfrlog: yeah core.clj don't work

18:25 davekong: maybe it is only when you say it is main

18:26 gfrlog: davekong: confirmed

18:26 davekong: and once again it loads it twice

18:29 mrnex2010: thank you very much guyse

18:32 Somelauw: I think I really hate emacs, but like its interaction mode. So I will just program in vim and refresh the file in emacs whenever I want to test something.

18:32 mrnex2010: srry gfrlog, where did you place the user.clj?

18:33 gfrlog: mrnex2010: src/user.clj

18:33 mrnex2010: ty

18:33 YaY!

18:37 amalloy: Somelauw: a lot of the benefit comes from things like having documentation available while editing

18:37 eg, start typing a function call and it gives you hints about what args it takes

18:38 * gfrlog starts pining

18:39 gfrlog: why nobody builds SLIMV?

18:39 amalloy: gfrlog: you need it built for you?

18:39 i can't tell if you're punning or clueless; slimv does exist, though i assume slime is better

18:40 gfrlog: oh I'm clueless

18:40 I need to learn to google before I announce stuff I make up

18:41 man if this thing works halfway decently that might be the nail in the coffin of me learning emacs

18:42 amalloy: gfrlog: you should hang out in here when someone asks how to install slimv

18:42 it's like having to invent the wheel every time you build a car. so many things to do

18:43 gfrlog: but every 5th question is about swank/slime

18:47 amalloy: gfrlog: right at the moment my slime is broken because i wanted to try out ritz. so i guess i'm not in a position to brag about slime's simplicity. although i did get it set up on a fresh ubuntu install in no time at all

18:48 gfrlog: what about SLIMW?

18:48 (Word)

18:49 sorry, I won't do it again...

18:52 amalloy: gfrlog: you should be able to put together a convincing demo of SLIMW by next april 1st

18:53 or the conj. surely there's space for some comic relief

18:55 gfrlog: amalloy: if it didn't require mucking about in all that windows stuff I'd think about it

18:55 amalloy: $google microsoft word apple osx

18:55 sexpbot: First out of 2600000 results is: Microsoft Office for Mac Downloads and Updates | Office For Mac

18:55 http://www.microsoft.com/mac/downloads

18:56 gfrlog: amalloy: half as gross

18:56 amalloy: *chuckle* sometimes you have to get your hands dirty for a laugh

18:57 gfrlog: now with manual syntax-coloring!

18:58 amalloy: heh

18:59 Clippy: It looks like you're trying to: call a function! Would you like me to insert the closing ")" for you? Y/N

18:59 gfrlog: oh I know which letter I'm clicking

19:00 it's never been easier to export your .clj files to outlook!

19:03 I wish I knew how to get jvisualvm to tell me the total executation time for the functions...

19:25 if (binding [*warn-on-reflection* true] ...) does not output any warnings, does that mean that there's no benefit to adding type hints to the code?

19:49 __name__: .w abdicate

19:49 ]dict abdicate

19:49 * gfrlog couldn't agree more

19:49 __name__: Gosh darned.

19:49 Tabs are evil.

19:49 How did I end up in this tab anyway?

19:50 gfrlog: you mean that wasn't some strange invocation of sexpbot?

19:50 __name__: I blame … GTK.

19:50 No it was not.

19:50 It was me being an idiot.

19:50 gfrlog: it looks like vim?

19:51 amalloy: $dict abdicate

19:51 sexpbot: amalloy: verb-transitive: To relinquish (power or responsibility) formally.

19:51 __name__: That would be :

19:51 amalloy: (for what it's worth)

19:51 gfrlog: :)

19:51 __name__: I blame the time of day.

19:51 It's 1.51 AM.

19:51 amalloy: gfrlog: i don't expect the (binding) to have any effect at all

19:51 you have to (set! *warn-on-reflection* true) before you compile the code

19:51 gfrlog: amalloy: this sounds like useful information

19:51 amalloy: because it's a flag that's checked at compile time

19:52 gfrlog: okay. So if I'm using lein, when does the code get compiled?

19:52 amalloy: uhhh

19:52 gfrlog: I guess "lein compile" would have to do it at some point

19:52 so then where should the (set! ...) go?

19:52 in my user.clj? :)

19:52 amalloy: gfrlog: i usually set! it in the repl before require'ing my code

19:53 gfrlog: that sounds worth a try. I'ma do it.

19:54 I think it worked.

19:54 amalloy: gfrlog: $ cake check

19:54 gfrlog: okay, so back to the original question -- does a type hint only help in a situation that produces a reflection warning?

19:54 amalloy: yes

19:55 gfrlog: this is weird because I get almost none

19:55 the only warning is when I call (.join ...) on a thread

19:55 amalloy: okay...so don't add type hints?

19:55 gfrlog: I guess so. :/

19:55 amalloy: you only need them if you're doing direct interop with (.foo) or really-really want to work with primitive numbers

19:56 gfrlog: I have some integer + :infinity arithmetic that I feel like is probably slower than it could be

19:56 amalloy: (and getting it right for primitives is a lot harder than you think)

20:03 gfrlog: but type-hinting can definitely help by getting you to work with primitives, even in the absence of reflection warnings

20:03 gfrlog: hmm :/

20:03 amalloy: it's just hard to do right

20:04 gfrlog: or I could use an array instead of a hash....

20:49 amalloy: gfrlog: i don't think i want to live in a universe where that suggestion makes sense

21:54 pcavs: Where's a good place to look (outside of the source) to see how Clojure implements its parallelism? I am under the impression that it is done automatically by the runtime + compiler, but maybe I am incorrect.

21:54 hiredman: you are

21:55 pcavs: incorrect?

21:55 Any places to look/read?

21:55 hiredman: yes

21:56 pcavs: http://clojure.org/concurrent_programming is the concurrency screencast good?

22:08 Is it possible to convert a string to a keyword?

22:14 sorry, stupid question

22:15 ,(keyword "My answer is thus")

22:15 clojurebot: :My answer is thus

22:16 amalloy: augh who put mixed tabs&spaces in clojure.xml?

22:25 hiredman: must be clojure/core

22:34 technomancy: !guards

22:34 oops

22:34 ~guards

22:34 clojurebot: SEIZE HIM!

22:36 seancorfield: quick Q... if i have a vector, is there a built in function to find the index of a given value?

22:37 and what's the bot command to find functions based on arguments

22:37 hiredman: ,(.indexOf [1 2 3] 1)

22:37 clojurebot: 0

22:37 seancorfield: oh.... a java method... that explains why i couldn't find it :)

22:38 i'm a bit surprised there isn't a clojure fn for that (but thank you hiredman )

22:40 what about finding the key in a map for which the value matches? (just curious now)

22:41 hiredman: nope

22:41 seancorfield: ok, just checking

22:41 (again, just a bit surprised)

22:41 technomancy: (zipmap (vals m) (keys m))

22:41 hiredman: ,(first (some (comp #{:a} second) {:z :a}))

22:41 clojurebot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword

22:41 technomancy: rich doesn't like to expose things unless they're performant; see contains?

22:42 hiredman: bleh

22:42 seancorfield: (somefn map value) was what i was looking for

22:42 (first (vals (filter (fn [[k v]] (= v stuff)) map))) was what i came up with (for stuff in map)

22:42 hiredman: technomancy: well, that is not a very performant solution

22:43 creating a reverse map

22:43 seancorfield: right

22:57 semperos: say I have an arbitrary map m which is {:a "y" :b "z"}, and I need to create (and (= "y" (:a m)) (= "z" (:b m))) to verify the values of the map

22:57 how would I go about generating that and expression?

22:58 seancorfield: do you want to test the whole map or just some key/value pairs?

22:58 semperos: whole map

22:59 seancorfield: so you can just test the whole map

22:59 (= {:a "y" :b "z"} other-map)

23:00 semperos: I'm actually using it as part of a clojureql `select` function, which is generating a SQL query behind the scenes from this and expression

23:00 I've been able to generate the and expression using templating

23:00 https://gist.github.com/1064187

23:01 but I'm not sure what to do with it, and was hoping there was some other way

23:13 pcavs: Hey, I'm trying to represent a 2D game-map. I was thinking of going with a vector of vectors, does that sound like a good idea? If so, what's the best way to define such a thing? The game-map is generated, so there's a variable number of rows and cols

23:28 amalloy: $findfn [1 2 3] 1 0

23:28 sexpbot: []

23:28 amalloy: seancorfield: ^ would get your answer if it were a plain function

23:29 seancorfield: thanx amalloy

23:30 amalloy: semperos: there's no way that gist makes any sense. you're not unquoting inside the for

23:30 seancorfield: $findfn [1 2 3] 2 2

23:30 sexpbot: [clojure.core/max-key clojure.core/cond clojure.core/dosync clojure.core/sync clojure.core/char-escape-string clojure.core/with-loading-context clojure.core/*clojure-version* clojure.core/case clojure.core/min-key clojure.core/and clojure.core/locking clojure.core/c... http://gist.github.com/1064215

23:30 seancorfield: :)

23:30 *clojure-version*... interesting match :)

23:31 amalloy: seancorfield: ##({:k :v} :whatever 2)

23:31 sexpbot: ⟹ 2

23:31 amalloy: but yes, clearly silly

23:33 semperos: clojure.core/and is, guaranteed, not the thing you want to be using here. i'd guess you want every?, but your gist doesn't really make it clear what your intent is if you don't like seancorfield's solution, so i can't solve it "for" you

23:33 semperos: amalloy: yeah, I realized it didn't make much sense

23:33 shouldn't tinker while watching movies with family :)

23:34 not looking for anyone to solve it for me

23:34 using clojureql.core/select to do a query of a database

23:34 I want to be able to have a map/record with certain keys that match column names in a database table

23:35 and write a function where I pass in this map/record and use all of the entries to fill out the "where" clause of the select function

23:35 basic use looks like (clojureql.core/select (table :foo) (where (= :id (:id my-map))))

23:36 amalloy: blugh. iirc clojureql has a lot of macro stuff, which makes this not easy

23:45 semperos: turns our clojureql's `where` macro for which I was trying to do this just puts together a WHERE clause as a string

23:46 since I already wrote code to mangle that with some functions for clojure.contrib.sql with strings, this is a non-issue

23:56 seancorfield: it's pretty easy to do that with clojure.java.jdbc already

23:57 https://gist.github.com/1064231

23:57 q and qi and naming strategies

23:58 updated gist with those

23:58 semperos: seancorfield: thanks for sharing

23:59 still using 1.2 myself, but that all makes sense

23:59 seancorfield: that's from our production code (hence ws/worldsingles-db-readonly)

23:59 semperos: yeah

23:59 seancorfield: naming strategies are new in c.j.j (compared to c.c.sql) but the rest should work

23:59 semperos: yep

23:59 seancorfield: you know you can depend on c.j.j 0.0.3 even tho' you're on clojure 1.2?

Logging service provided by n01se.net