#clojure log - Jul 30 2011

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

0:00 lucca: I think the second 'dynamic' there means "on the fly" rather than dynamic vs lexical

0:00 hiredman: lucca: that doesn't make any sense

0:00 lucca: But! I'm very very new and still learning clojure.

0:01 hiredman: how so?

0:01 amalloy: agreed, that doesn't make sense. the second one is the one that explicitly says "dynamic vs lexical"

0:01 hiredman: lucca: oogada boogada

0:01 amalloy: hahahahaha

0:01 here in #clojure we encourage the ability to count to two; ability to form sentences using words is optional

0:02 lucca: I miscounted; I meant the third dynamic

0:02 the one at the END at any rate

0:03 hiredman: the cunning plan is to lure lucca into "saying well that doesn't make sense" and I say "how so?"

0:03 saying "

0:03 lucca: hahahah

0:05 amalloy: hiredman: well, re-bait that hook; i'm sure someone less careful will say something senseless soon

0:10 technomancy: blog post contains "it's a more work"

0:13 hiredman: he also missed my entire rant about C's global codespace vs. jvm land

0:13 but I guess it's his blog

0:40 technomancy: hiredman: actually my point was that the global codespace works fine for users

0:40 just not for devs

0:41 amalloy: thanks

0:43 how does cpan run library tests? do they just use a chroot jail or what?

0:43 hiredman: technomancy: I dunno, the jvm hasn't been around to accumulate tooling as much as C has

0:43 (end user package managers

0:43 )

0:43 technomancy: they must have safeguards in place to prevent people from using cpan as spam relays and such, right?

0:48 Blackfoot: how should I extend types in clojurescript? just use (.extend Class {...})?

0:50 amalloy: probably deftype or reify? i suspect cljs frowns on extending classes just as much as clj does

0:53 technomancy: so I was thinking... what would clojars look like if it had continued to develop instead of stalling out?

0:54 brainstorming, lots of metadata: URL, license, last update (commit frequency?), LOC/Test LOC, tests pass?, coverage, docs, dependency tree

0:54 amalloy: ~skynet

0:54 clojurebot: I will become skynet. Mark my words.

0:54 technomancy: I think test failures and maybe coverage are really the only things there that are really unreasonable given the current infrastructure

0:54 amalloy: technomancy: actually, coverage isn't that hard to get kinda-sorta right

0:55 i added a coverage task to cake a few weeks ago

0:55 technomancy: amalloy: sure, simplistic coverage can be done with radagast

0:55 I'm more concerned about the sandboxing issue

0:55 amalloy: $google radagast

0:55 lazybot: [Radagast - Wikipedia, the free encyclopedia] http://en.wikipedia.org/wiki/Radagast

0:55 technomancy: https://github.com/technomancy/radagast

0:56 amalloy: not even in the wiki disambig

0:56 hiredman: clojars would sprout an rss feed instead of me having to scrap the page

0:56 technomancy: amalloy: oh dang; I'll add it

0:56 hiredman: fo sho

0:56 not even showing the link from the pom is tres silly

0:57 amalloy: technomancy: looking at the source - you're testing namespaces, yeah?

0:58 cake coverage takes a totally different approach. looks up all your public functions, then searches for each (by name) in the source code of test files

0:58 technomancy: amalloy: uhhh

0:58 amalloy: i'm not asserting that this is a better approach

0:58 technomancy: so (when false (my-fun)) would count my-fun?

0:59 amalloy: yes. obviously it's not perfect

0:59 but it works surprisingly well for *actual* tests

0:59 as opposed to invented worst-cases

0:59 technomancy: so branch-level coverage is obviously really hard without compiler hooks

0:59 amalloy: technomancy: robert hooke might be good for that though?

0:59 technomancy: but var level coverage is trivial

1:00 I think you'd need a cinc compiler to hooke conditionals

1:00 amalloy: no, i mean for var-level

1:00 technomancy: oh yeah, sure

1:00 amalloy: but you have to actually *run* the tests to see what your coverage is like, if you use hooke. for large test suites, that can be a problem; i like the ability to quickly say "hey what do i have left to add tests for"

1:00 technomancy: actually since you don't need it to compose it's just alter-var-root

1:01 amalloy: fair enough

1:01 technomancy: I guess your version is also a lot easier to run from something like clojars

1:01 amalloy: right

1:01 technomancy: but... I don't think coverage is actually useful unless you've also confirmed tests pass

1:02 so before any knowledge about the test suite can be considered valuable, you pretty much have to run it

1:02 amalloy: technomancy: (a) don't really agree

1:02 (b) tests won't all run on clojars anyway. the db server you're testing against won't be installed

1:03 technomancy: for applications, probably not. but for oss stuff most of them probably would.

1:03 any sql test suites should be able to run against an in-process derby

1:03 amalloy: technomancy: aleph-redis?

1:04 technomancy: sure, there are libs with external system-level dependencies

1:04 but they're the minority

1:04 amalloy: but anyway, i think that even var-level coverage is pretty useful to have on clojars, without needing to know if the tests pass

1:05 a library with 80% of its public vars having at least *some* tests is way better than a library with no tests at all

1:05 technomancy: yeah, I mean to a degree you can trust the author

1:05 hiredman: *shrug*

1:06 clojurebot: tests |are| <reply> meh

1:06 clojurebot: In Ordnung

1:06 technomancy: turning clojars into free CI is probably not a sustainable approach anyway

1:06 I'm just curious about it because apparently CPAN pulls it off

1:08 I keep trying to rope in newcomers looking for a project to clojars, but it doesn't seem to stick.

1:08 maybe with ato returning from his MIA status there's a chance

1:09 dakrone: technomancy: is there a todo?

1:09 totally easier to work from a project with a todo

1:09 technomancy: dakrone: just a mailing list thread iirc

1:10 http://groups.google.com/group/clojars-maintainers/browse_thread/thread/d4149ec96316d5b1

1:10 actually plenty of enhancements on https://github.com/ato/clojars-web/issues too

1:11 problem is the install instructions don't work for the SCP service out of the box

1:12 hiredman: need a java scp service

1:13 technomancy: maybe we can swing it as a seajure hack project

1:14 hiredman: http://mina.apache.org/sshd/

1:14 technomancy: also need to get pjstadig to finish procrustes

1:15 hiredman: huh... wonder if that was stable when clojars was created

1:15 hiredman: "SSHD provides a CommandFactory to support SCP that can be configure in the following way:"

1:15 technomancy: sick logo

1:15 hiredman: maybe not

1:21 http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/SshServer.java?view=markup 516 looks like it has the hooks for auth you'd need

2:16 grant__: hey guys, making a game in clojure. i put the whole game in a (future) so that i can interact with it with the REPL. but unfortunately that seems to make all error output go away...which is crucially important! anyone know a solution to this problem?

2:16 i'm using vim and vimclojure

2:44 amalloy: $google raek executor clojure binding

2:44 lazybot: [brehaut.net] http://brehaut.net/links/

2:44 amalloy: wth

2:45 grant__: http://blog.raek.se/2011/01/24/executors-in-clojure/

2:48 grant__: wow, whenever i come in here you help me out

2:48 i feel like i owe you something :P

3:35 triyo: I'm trying to figure out how to call this this snippet from my third-party javascript library ... new Showdown.converter().makeHtml(txt) from my ClojureScript code

3:36 I tried (js* "new Showdown.converter().makeHtml(~{b-txt}, ~{safe})") which didn't work. It said that the .converter is undefined which is very strange because I just use the library directly in my html, all work fine.

3:36 Showdown though is defined and its an object..

3:37 Now I'm trying to do something like...showdown (js* "Showdown") .... (.makeHtml (.. showdown (.converter)) txt))

3:38 Anyone have a clue what the code should look like in cljs?

4:08 lobotomy: morning folks

4:09 what's a good way to make a static id counter thing in clojure? in my java program, i have: private static long counter = 0; public static synchronized long getNextId() { return counter++; }

4:11 (my use case there is to just create a unique human-readable "name" for each thing to help with debugging)

4:13 amalloy: lobotomy: ##(doc gensym)

4:13 lazybot: ⇒ "([] [prefix-string]); Returns a new symbol with a unique name. If a prefix string is supplied, the name is prefix# where # is some unique number. If prefix is not supplied, the prefix is 'G__'."

4:16 lobotomy: amalloy, awesome, cheers

4:17 ohwow_: Also: (def incr (let [x (ref 0)] (fn [] (dosync (ref-set x (inc @x))))))

4:17 ,(def incr (let [x (ref 0)] (fn [] (dosync (ref-set x (inc @x))))))

4:17 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

4:17 ohwow_: uh

4:19 amalloy: ohwow_: no offense but i'm gonna throw up, there

4:19 (a) an atom would do fine here, there's no need to synchronize multiple refs; (b) you're looking for alter, not ref-set

4:26 ohwow_: okay, sorry

4:26 i am a clojure newbie

4:26 amalloy: i know. don't take offense; i'm pointing it out so you'll know how to improve

5:17 Pupeno: Anybody awake?

5:26 dedeibel: zzzZZzzz

5:28 * ampleyfly pokes dedeibel inappropriately

5:30 dedeibel: »you will find out that dedeibel was only a watermellon with a wig and an old cassette recorder making sleeping noises«

5:31 ampleyfly: I will look forward to that

6:11 Pupeno: Where I work we have monthly hack days, when we all spend a whole day working on whatever we want, from future products to open source projects. I want to do something Clojure related that will help me learn Clojure better and that also gives back to the community. Any ideas what it could be? I think of two potential tasks: add examples to the documentation of clojure itself (many functions are missing examples that can help understand them)

6:11 maybe work on clooj.

6:12 Any other ideas?

6:15 djpowell: just playing with clojurescript - is there anyway to include additional javascript files to be processed by the closure compiler?

6:16 i've created a closure template, and can't figure out how to call it from clojurescript

7:00 laker: hey, what's the best way to handle thousands of connections with clojure?

7:02 _ato: laker: as in TCP sockets? or HTTP? or...?

7:03 laker: yeah, tcp

7:04 and it needs to be async

7:04 1 agent per client going to work?

7:05 _ato: if you just use normal java sockets then you'll end up with one thread per socket, which is not scalable past a certain point

7:05 you really need select() which is available through nio http://download.oracle.com/javase/6/docs/api/java/nio/channels/Selector.html

7:05 it's not very easy to use unfortunately though

7:06 laker: yeah i saw that, but i was thinking if there was an easy way

7:06 using the clojure primitives

7:07 kinda want to use clojure instead of erlang and doing 1 process/client with erlang is great

7:10 _ato: Aleph might be relevant: https://github.com/ztellman/aleph

7:10 I haven't played with it so can't give an opinion on it

7:10 laker: i'll check it out, thanks

7:39 problem: (defmacro m [b] `(do ~@b))

7:39 (defn t [& b] (m b))

7:40 got "Don't know how to create ISeq from: clojure.lang.Symbol"

7:40 I can't figure it out, can anyone explain that to me? thx

7:41 jcromartie: problem: you are trying to unquote paste (~@b) a symbol

7:41 ~@ takes a sequence and puts its contents directly into the macro... so

7:41 clojurebot: @ has nothing to do with whether sth is evaluated or not

7:42 jcromartie: (m b) tries to use the symbol 'b as a sequence

7:42 (defmacro m [& b] `(do ~@b)) is probably what you mean

7:43 then b is going to be a sequence of each argument to m

7:44 problem: jcromartie: thanks for the explanation, but what if i want to pass a sequence to a macro from inside a function?

7:48 _ato: if the intention is that you can do something like: (t '[(println "hello") (println "world")]) that's not going to be possible. The sequence doesn't exist at compile-time and the macro doesn't exist at run-time.

7:49 jcromartie: problem: maybe you are looking for "apply" ?

7:49 what's your goal, problem

7:50 problem: what kind of code are you trying to write

7:52 problem: I am writing something a bunch of functions that use a macro, the functions must take arbitrary arguments.

7:53 jcromartie: OK :)

7:54 well, do you understand how to use & ?

7:54 problem: sure i do

7:54 jcromartie: k

7:54 and apply?

7:54 problem: yes i do

7:54 jcromartie: (defmacro m [& args] `(do ~@args)) (defn f [& args] (apply m args))

7:55 problem: that solves the problem, thank you very much

7:55 ohwow_: could you do (defmacro m [a] `(do ~a)) and (defn f [& args] (m args)) ?

7:56 jcromartie: herp

7:56 actually

7:56 _ato: macros can't be applied

7:56 jcromartie: yeah

7:56 thanks _ato

7:56 I think we're back to solving the wrong problem, though

7:56 ohwow_: macros could not be used as HOF

7:57 So, would my code work?

7:57 _ato: well, except http://richhickey.github.com/clojure-contrib/apply-macro-api.html

7:57 but that just uses eval

7:57 jcromartie: OK but for our friend problem here

7:58 problem: your name makes parts of this conversation quite ambiguous

7:58 _ato: hehe

7:58 problem: :)

7:59 * jcromartie wishes he could /nick other people

8:00 _ato: I don't think there's a good way to do it except to rewrite the macro as a function

8:04 problem: so does that mean it is generally better to define a macro calling functions instead of to define functions calling macros?

8:07 _ato: yes. actually it's best to not use macros at all if possible for exactly this kind of reason. they're not as composable as functions

8:08 problem: that makes sense

8:09 triyo: Enlive selectors, is there a way to pass in a value for an id? So instead of [:div#nav :li#specificId] (set-attr :class "active") .... I can do [:div#nav :li#(my-value-passed-in-via-fn] (set-attr :class "active")

8:10 ejackson: so weird. in clojurescript when I call methods for Library objects I get the associated code back, rather than the result of executing it

8:10 anybody seen this ?

8:12 triyo: ejackson: I know why

8:12 ejackson: groovy

8:12 triyo: its a bit different to clojure way of calling methods ion instances

8:13 ejackson: https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure look at the Host interpo section

8:13 ejackson: you may be my new hero !

8:14 triyo: You need something like (. sb (toString))) so you need to surround the toString with a set of parenthesis in order to execute the method itself rather than get back the the function def intself

8:14 ejackson: checking this out...

8:15 triyo: From Clojure -> ClojureScript thats a one common gotcha I'd say so far

8:15 ejackson: triyo: thanks dude ! that worked out

8:15 triyo: you welcome

8:16 ejackson: its been fun getting the Library gui stuff going

8:51 triyo: Does "slurp" function work with relative paths too?

8:51 I have a web app that slurps a content of a file and I wish to only provide the relative path.

8:53 However, what is the best way to get the relative path and also what is the relative path based on?

8:53 classpath or the location of the file that slurp is ran in/

8:53 ?

9:04 ejackson: triyo: dunno, sorry, no karma payback :(

10:35 triyo: thanks for the gotcha help. shouted out in post about this stuff: http://boss-level.com/

11:58 fmw: how do I set an attribute in ClojureScript? e.g. the equivalent of

11:58 goog.dom.getElement("slug").value = "foobar";

11:59 (.setAttribute (dom/getElement "slug") "value" "foobar") works initially, but the value doesn't change anymore after I manually type something in the <input /> element

11:59 Blackfoot: fmw: set!

12:00 fmw: Blackfoot: thanks!

12:01 Blackfoot: yup. haven't tried it with value, but it works for function assignments and fontSize at least :)

12:06 fmw: Blackfoot: thanks, you are my hero. it works :)

12:06 must've spent 45 minutes trying to figure out how to set an attribute ;)

12:14 the-kenny: I'm currently using prn-string and read-string for communication between a client/server Clojure & ClojureScript application. However, there seems to be a problem regarding keywords. On the Clojure side, everything works find. Trying to get the name of a keyword gives the same unicode-prefix just like (str :keyword)

12:16 :foo translates to ﷐'foo

12:17 As far as I know, this is intended. However, (name :foo) should give me "foo", right?

12:20 Blackfoot: not sure what you mean by unicode prefix?

12:20 the-kenny: Keywords in ClojureScript are represented as Strings with a specific prefix

12:20 \uFDD0

12:21 Blackfoot: ah i see

12:21 the-kenny: There's a problem in my application which makes keyword? and name fails to realize that the given string is a keyword

12:22 (keyword? :foo) returns false in my project :(

12:23 I'll try re-bootstrapping my ClojureScript

12:25 hm, still doesn't work when running in browser.

12:25 Blackfoot: (keyword? :foo) returns false in your browser?

12:26 the-kenny: Yup

12:26 Same code returns true in script/repljs

12:27 Blackfoot: checking

12:27 the-kenny: (keyword? :foo) gets compiled to: cljs.core.keyword_QMARK_.call(null,"﷐'foo")

12:28 (just want to mention it)

12:31 Blackfoot: yea, interesting, i'm seeing that, too

12:32 the-kenny: Hah, at least I'm not the only one :)

12:34 There's a difference between "\uFDD0'foo" and (keyword "foo"). At least it prints differently in the javascript console

12:36 Blackfoot: the-kenny: i think the problem is charAt is not unicode sensitive

12:37 the-kenny: keyword? is essentially x.charAt(0)==\uFDDO

12:37 the-kenny: yup, I have the source in front of me

12:42 Blackfoot: hrm, maybe not. i see what you're saying, I see two characters proceding the keyword in the console

12:43 the-kenny: Maybe a problem of the compiler with unicode strings?

12:46 Seems to be an encoding problem. The emitted strings are correct prior loding the files in the browser

12:48 Blackfoot: i'm loading html files directly from disk. i wonder if ContentType isn't being set correctly?

12:48 the-kenny: I'm loading them from the disk too. Let me try it on a webserver

12:53 Hm. I don't know how to set content-encoding on OSX' built-in webserver :) Sorry

12:54 Blackfoot: i'm using chrome, and i fixed it be going to wrench->tools->encoding->Unicode

12:57 the-kenny: adding <meta http-equiv="Content-Type" content="text/html" charset="UTF-8"> to the html fixed it too

12:57 Blackfoot: ah nice

13:00 the-kenny: are you just trying out clojurescript, or are you using a framework? (eg compojure)

13:01 the-kenny: I'm working on a web interface (websockets) for a turn-based game I'm working on

13:01 Server-Side will most likely use compojure in the future, but it's currently only a single html file

13:01 And the we interface isn't very mature yet :) Just started a few days ago

13:02 Blackfoot: cool. i'm wondering what setup to get started on. if people are going to end up using closure templates and such

13:04 the-kenny: I just made clojurescript a subproject of my project and fire up a repl for compiling clojurescript. Server side hacking is done via Slime

13:04 There is much room for improvement

13:07 MasseR: Now if only clojurescript worked on openjdk :P

13:19 the-kenny: Hah, now I can remove some hacks :) Thanks Blackfoot

13:19 Blackfoot: team effort :)

14:03 TimMc: OK, I'd like to make a small Clojure-based website that has a database. What's a good option for hosting?

14:04 and for databases, for that matter.

14:05 peteriserins: TimMc: Heroku, perhaps?

14:06 TimMc: here's an appropriate blog post: http://thecomputersarewinning.com/post/clojure-heroku-noir-mongo

14:12 TimMc: Cool, I'll check that out.

14:12 Oh, is Google App Engine still popular?

14:14 Scriptor: it has its niche :p

14:15 TimMc: And what is that niche?

14:17 Scriptor: either for quick testing or hosting sites that don't expect all that much traffic early on, so a good place to start

14:17 I don't know how easy it is to set up a clojure app on there, though

14:18 TimMc: Quick startup is good.

14:18 This is just an experimental thingy.

14:18 Scriptor: then both heroku and GAE should be fine

14:18 TimMc: hmm, OK

14:20 The Users API on Google App Engine looks nice.

14:37 jweiss: is it bad to have a promise inside the value of an atom?

14:37 i am not sure what happens to the atom when the promise is delivered, i guess that doesn't count as a change to the atom?

14:38 eg (def blah (atom {:this "hi" :that (promise)}

14:42 danlarkin: yeah you can deliver to the promise "outside" of the atom

14:43 (let [a (atom (promise))] (deliver @a :foo) @a)

14:43 ^ that changes the state of the atom without swap! or reset!

15:10 jweiss: hm, in the java.util.concurrent.Executors class, the submit method has 2 overloads, one that takes Callable, and one that takes Runnable. i want to invoke the callable one.

15:11 but i keep getting back nil when i pass a clojure fn in there, i think it's because fn's are both runnable and callable.

15:11 danlarkin: yes, I've had the same situation -- hint it

15:11 jweiss: tried type hint ^Callable (fn [] "blah") but didn't hel

15:11 p

15:11 did i do the hint wrong?

15:12 i did (def x (.submit *pool* ^Callable (fn [] "hi there")))

15:12 if i do (.get x) -> nil. should get "hi there"

15:13 danlarkin: try (let [f ^Callable (fn [] "hi there")] (def x (.submit *pool* f )))

15:15 jweiss: danlarkin: that didn't help

15:17 goodieboy: anyone know what emacs starter-kit to go with? seems to be several clones on github...

15:18 technomancy: are you still working on your emacs-starter-kit? or is eschulte's the one to go with?

15:44 technomancy: goodieboy: I'm working on the v2 branch currently

15:44 it's a little different and requires emacs 24

15:44 goodieboy: ah ok. yeah i'm using master now

15:45 hey not sure if you do any ruby or not but.. do you know of a good ruby setup for emacs?

15:46 technomancy: schulte's might be better for ruby; I haven't kept up with that at all

15:46 goodieboy: ok cool, i might give that a shot

15:46 thanks

15:47 technomancy: I'm keen on finding a maintainer for the ruby portion of the starter kit v2 though

15:47 just hasn't happened

15:48 goodieboy: awesome, good to know

17:28 lobotomy: howdy again. i need to bitwise invert 5-bit numbers. how's this solution: (let [l [16 8 4 2 1]] (apply + (map * (reverse (map #(/ (bit-and n %) %) l)) l)))

17:30 (ok, 5 bits is small enough that i'll just store that in a lookup table, but yeah)

17:38 sritchie: lobotomy: here's a function I wrote for flipping float bits -- https://gist.github.com/1116033

17:40 it should do the trick, without the precondition (or that final Float/intBitsToFloat operation

17:40 amalloy: lobotomy: just bit-xor with 0x1f?

17:40 sritchie: oh, sorry, wrong problem -- somehow interpreted bitwise inversion as endian inversion

17:41 amalloy: &(map (partial bit-xor 0x1f) [5 11 18 30])

17:41 lazybot: ⇒ (26 20 13 1)

17:41 amalloy: or even just subtract from 0x1f, which i guess is the same thing?

17:44 lobotomy: hmm... but 18 = 10010_2 -> inverted 01001_2 = 9, not 13

17:45 amalloy: uh, that's not inversion. you missed a bit

17:45 it inverts to 01101, which in fact is 13

17:47 lobotomy: i don't follow. isn't 18 in binary 10010? and isn't (apply str (reverse "10010")) "01001"?

17:49 amalloy: lobotomy: you want to reverse the bits? really? then don't say invert, which means something totally different

17:49 lobotomy: ahh, of course... my bad

17:49 sritchie: lobotomy: that gist above will do the trick, then -- amalloy helped me with that one a while back

17:52 lobotomy: i'm writing a puzzle solver, with pieces that consist of edges, and each edge has an invert-edge function (or however that should be done in clojure), which is where i got the terminology :)

17:53 amalloy: $javadoc Integer toString

17:53 lazybot: http://download.oracle.com/javase/6/docs/api/java/lang/Integer.html#toString(int,%20int)

17:54 lobotomy: in the java version each edge is paired with another (version of the same) edge that points in the opposite direction, at construction time; these are both immutable so the inversion is just done once

17:54 i'm trying to figure out if i should do that in the clojure version too, or whether that's premature optimisation

17:55 amalloy: &(-> 18 (Integer/toString 2) reverse (->> (apply str)) (Integer/parseInt 2))

17:55 lazybot: ⇒ 9

17:55 amalloy: that's probably no good, actually

17:56 yeah. doesn't pad

17:56 lobotomy: if i don't store the inverted versions then i'll need to create another edge each time an inverted version is needed, and in theory the jvm might not cache or optimise those parts of the code so hmm... yeah, premature optimisation ;)

18:32 duck1123: is there a logging api for clojurescript, or do I have to use goog.debug

18:41 jweiss: I'm having trouble type hinting a clojure fn as a Callable - no matter what i do the ExecutorService runs it as a runnable, and returns nil

18:45 dnolen: jweiss: reify Runnable and put the fn inside?

18:45 jweiss: dnolen: you mean callable?

18:46 dnolen: jweiss: yeah

18:46 jweiss: i would have thought this was exactly what type hints were for, not sure why they don't work

18:46 ie, (.get (.submit *pool* ^Callable (fn [] "hi")))

18:46 returns nil

18:46 amalloy: jweiss: is pool hinted also?

18:47 if not, the other hint won't do any good

18:47 jweiss: amalloy: no, i didn't realize i had to hint that too

18:47 i have to hint the object type if i want to hint a method arg type?

18:48 amalloy: if the compiler can't compile into a statically typed method call, it has to use reflection. once it's using reflection, i wouldn't be surprised if it discarded the typehint

18:49 jweiss: so i tried (.get (.submit ^ExecutorService *pool* ^Callable (fn [] "hi")))

18:49 still returns nil

18:49 i do still get reflection warning

18:50 amalloy: and how is pool created? i'll try to reproduce locally

18:50 jweiss: amalloy: (def *pool* (Executors/newFixedThreadPool 2))

18:51 amalloy: $javadoc java.util.concurrent.ExecutorService

18:51 lazybot: http://download.oracle.com/javase/6/docs/api/java/util/concurrent/ExecutorService.html

18:51 jweiss: amalloy: yeah i have that page up

18:51 amalloy: well, i didn't

18:51 jweiss: oh

18:52 i thought that was for me :)

18:52 seems to me that somehow the submit(Runnable ) is invoked instead of submit(Callable)

18:54 amalloy: for me it refuses to compile with the typehints in

18:54 jweiss: i tried setting the fn in a let, like this:

18:54 (let [^Callable f (fn [] "yo")] (.get (.submit ^ExecutorService *pool* ^Callable f)))

18:54 that works

18:54 amalloy: but try (let [^Callable f (fn [] "")] (.get (.submit ^ExecutorService *pool* f)))

18:54 jweiss: ah right forgot the 2nd hint

18:54 works without the 2nd one

18:55 according to clojure type hint docs, you can hint an expression

18:55 but that doesn't seem to work here

18:55 amalloy: jweiss: the second typehint makes no difference to me

18:55 jweiss: right, me either

18:56 i just forgot to remove it

18:59 neotyk`: amalloy: jweiss: why you have to hint it? this works for me: (let [f (fn [] "yo")] (.get (.submit *pool* f)))

19:01 jweiss: neotyk`: that does not work for me.

19:01 i'm on clojure 1.2

19:02 i also tried the suggestion of reify, that also works

19:02 amalloy: jweiss: interestingly, try (.get (.submit ^ExecutorService *pool* ^Callable (identity (fn [] ""))))

19:02 neotyk`: I'm on 1.2.1

19:02 jweiss: amalloy: that works also

19:02 ohhh

19:02 amalloy: right

19:02 jweiss: one thing i just realized, i am working in a ns that uses serializable.fn

19:03 lemme switch

19:03 amalloy: i think clojure must be special-casing that into "a function hinted to return Callable"

19:05 jweiss: well, i may just stay away from the type hint voodoo and use reify :)

19:16 st3fan: hey what is the best slime version to grab?

19:16 i see many forks, not sure which one is the best one for clojure work

19:17 amalloy: jweiss: yeah, confirmed that ^Callable (fn [] x) means "function returning Callable"

19:17 (.get (.submit ^ExecutorService *pool* ^Callable ((fn[] (fn [] "")))))

19:25 jweiss: amalloy: ah, that makes it less voo-doo-ey

19:25 amalloy: really? just slapping an identity on the front feels cleaner to me

19:25 jweiss: amalloy: no, i mean you telling me why it behaved like that

19:26 amalloy: thought i already had. i guess 'i think clojure must be special-casing that into "a function hinted to return Callable"' wasn't clear enough

19:27 jweiss: amalloy: it was clear but I didn't read carefully

19:27 st3fan: hm when i am on emacs 23.3, is ELPA a good way to install all the stuff i need for clojure?

19:29 amalloy: for an amusing precedent see, eg, ##(macroexpand '(.getName java.util.regex.Pattern))

19:29 lazybot: ⇒ (. (clojure.core/identity java.util.regex.Pattern) getName)

19:38 duck1123: does doseq work in clojurescript for going over a collection of elements?

19:38 I seem to be getting an error from seq

19:41 JoelMcCracken: if I were to create a simple web application in clojure, where would it be best to proceed from? (taking into account http://stackoverflow.com/questions/3325033/comparison-of-clojure-web-frameworks , however this is from a year ago)

19:41 st3fan: JoelMcCracken: i'm looking at Noir

19:42 JoelMcCracken: ah, sinatraesque

19:42 duck1123: getting started, you'll probably be best off with compojure

19:42 amalloy: JoelMcCracken: noir is supposed to be good, but i like the more hands-on approach of using ring, compojure, and hiccup

19:42 st3fan: compojure looks good too

19:42 any good tutorials you guys recommend?

19:43 JoelMcCracken: i think i'll probably go that route

19:43 duck1123: shameless plug for https://github.com/duck1123/ciste

19:43 JoelMcCracken: as per amalloy's suggestion and duck1123

19:44 ha =) i may try it someday

19:48 st3fan: i am evalling a function in my src/hello/core.clj .. but i am greeted with "Unable to resolve symbol: defn in this context"

19:48 i just hit C-c C-c right?

19:49 i'm a bit stuck of what to do after slime-connect :-/

19:49 amalloy: st3fan: try C-c C-k

19:49 mefesto: st3fan: C-x C-e to eval a single form i believe

19:49 amalloy: yeah, i never use C-c C-c anymore. C-M-x is just as good, and breaks less often

19:50 st3fan: cool

19:50 so i have (ns hello.core) on top

19:51 does that mean i access things in the repl like (hello.core/foo) ?

19:51 Scriptor: yep

19:51 amalloy: just foo is fine, if you put your repl in that namespace

19:51 Scriptor: there's a shortcut for putting the repl in the namespace of the file you're currently in

19:52 st3fan: otherwise just (in-ns 'hello.core) ?

19:52 mefesto: st3fan: also, if you want to stay in the user namespace then you can 'require or 'use it

19:52 Scriptor: amalloy: what's the shortcut for that?

19:52 amalloy: C-c M-p

19:52 st3fan: ah yeah that is a nice shortcut

19:53 so all the dependencies that i added in project.clj are added to the classpath right?

19:54 mefesto: st3fan: should be. did you start swank with `lein swank` ?

19:55 st3fan: or clojure-jack-in

20:01 hanDerPeder: how can i get M-. to work with symbols defined in the current project?

20:01 st3fan: lein swank

20:01 ok i think i'm good enough setup to start playing with some real code

20:08 mefesto: is hiccup the preferred html rendering lib for clojure web apps?

20:12 duck1123: I was using Hiccup, but I just switched to the Google Closure templates

20:13 but that's only because I intend to use them from clojurescript

20:13 mefesto: ah, i just ordered a book on G Closure to get somewhat up to speed on all that stuff

20:13 duck1123: hiccup used a lot less typing

20:13 mefesto: looks pretty interested from the mild reading i've done on it

20:13 duck1123: the one with the bird?

20:14 mefesto: yea, "Closure: The Definitive Guide"

20:14 duck1123: have the pdf open as we speak

20:15 mefesto: have you used g closure long?

20:15 duck1123: trying to figure out why I can't loop over these elements

20:15 couple hours

20:16 I'm just now writing my script, did my template conversion over the past week

20:32 seq is supposed to work for arrays, right? I keep getting errors.

20:35 Scriptor: it'll convert an array into an insteance of ISeq

20:36 duck1123: and that's where the exception is hapening

20:36 looks like it's hapening in the else block of ISeqable

20:37 should I be following master, or should I stick to "stable" builds if there are any?

20:47 for the record (dorun (for [i (range (alength elements))] (aget elements i))) did the trick

20:47 not as natural as doing simply (doseq but it'll do

21:11 st3fan: is org.clojure/java.jdbc decent?

21:11 or should i use something else?

21:19 scottj: st3fan: if that's the new clojure.contrib.sql, then that's by far the most popular tool. you could also look at clojureql

21:19 ohpauleez: st3fan: It depends on what you're looking for. It's very decent, you might want to also look at clojureql

21:23 st3fan: :-)

21:23 oh wait it moved to clojure.contrib?

21:24 i grabbed this from org.clojure/java.jdbc

21:25 scottj: sounds fine

21:34 amalloy: st3fan: it moved *from* contrib

21:36 contrib is, over the course of the next hundred years, being dismantled into several separate libraries

21:38 ohpauleez: haha, well put

21:52 st3fan: oh

23:04 lucca: I've tried lein search, but it seems to want to download a maven index, which now seems to be forbidden... is there a workaround or a better way to do these things?

23:11 goodieboy: anyone using noir?

Logging service provided by n01se.net