2011-07-30
| 00:00 | lucca | I think the second 'dynamic' there means "on the fly" rather than dynamic vs lexical |
| 00:00 | hiredman | lucca: that doesn't make any sense |
| 00:00 | lucca | But! I'm very very new and still learning clojure. |
| 00:01 | lucca | hiredman: how so? |
| 00:01 | amalloy | agreed, that doesn't make sense. the second one is the one that explicitly says "dynamic vs lexical" |
| 00:01 | hiredman | lucca: oogada boogada |
| 00:01 | amalloy | hahahahaha |
| 00:01 | amalloy | here in #clojure we encourage the ability to count to two; ability to form sentences using words is optional |
| 00:02 | lucca | I miscounted; I meant the third dynamic |
| 00:02 | lucca | the one at the END at any rate |
| 00:03 | hiredman | the cunning plan is to lure lucca into "saying well that doesn't make sense" and I say "how so?" |
| 00:03 | hiredman | saying " |
| 00:03 | lucca | hahahah |
| 00:05 | amalloy | hiredman: well, re-bait that hook; i'm sure someone less careful will say something senseless soon |
| 00:10 | amalloy | technomancy: blog post contains "it's a more work" |
| 00:13 | hiredman | he also missed my entire rant about C's global codespace vs. jvm land |
| 00:13 | hiredman | but I guess it's his blog |
| 00:40 | technomancy | hiredman: actually my point was that the global codespace works fine for users |
| 00:40 | technomancy | just not for devs |
| 00:41 | technomancy | amalloy: thanks |
| 00:43 | technomancy | how does cpan run library tests? do they just use a chroot jail or what? |
| 00:43 | hiredman | technomancy: I dunno, the jvm hasn't been around to accumulate tooling as much as C has |
| 00:43 | hiredman | (end user package managers |
| 00:43 | hiredman | ) |
| 00:43 | technomancy | they must have safeguards in place to prevent people from using cpan as spam relays and such, right? |
| 00:48 | Blackfoot | how should I extend types in clojurescript? just use (.extend Class {...})? |
| 00:50 | amalloy | probably deftype or reify? i suspect cljs frowns on extending classes just as much as clj does |
| 00:53 | technomancy | so I was thinking... what would clojars look like if it had continued to develop instead of stalling out? |
| 00:54 | technomancy | brainstorming, lots of metadata: URL, license, last update (commit frequency?), LOC/Test LOC, tests pass?, coverage, docs, dependency tree |
| 00:54 | amalloy | ~skynet |
| 00:54 | clojurebot | I will become skynet. Mark my words. |
| 00:54 | technomancy | I think test failures and maybe coverage are really the only things there that are really unreasonable given the current infrastructure |
| 00:54 | amalloy | technomancy: actually, coverage isn't that hard to get kinda-sorta right |
| 00:55 | amalloy | i added a coverage task to cake a few weeks ago |
| 00:55 | technomancy | amalloy: sure, simplistic coverage can be done with radagast |
| 00:55 | technomancy | I'm more concerned about the sandboxing issue |
| 00:55 | amalloy | $google radagast |
| 00:55 | lazybot | [Radagast - Wikipedia, the free encyclopedia] http://en.wikipedia.org/wiki/Radagast |
| 00:55 | technomancy | https://github.com/technomancy/radagast |
| 00:56 | amalloy | not even in the wiki disambig |
| 00:56 | hiredman | clojars would sprout an rss feed instead of me having to scrap the page |
| 00:56 | technomancy | amalloy: oh dang; I'll add it |
| 00:56 | technomancy | hiredman: fo sho |
| 00:56 | technomancy | not even showing the link from the pom is tres silly |
| 00:57 | amalloy | technomancy: looking at the source - you're testing namespaces, yeah? |
| 00:58 | amalloy | 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 |
| 00:58 | technomancy | amalloy: uhhh |
| 00:58 | amalloy | i'm not asserting that this is a better approach |
| 00:58 | technomancy | so (when false (my-fun)) would count my-fun? |
| 00:59 | amalloy | yes. obviously it's not perfect |
| 00:59 | amalloy | but it works surprisingly well for *actual* tests |
| 00:59 | amalloy | as opposed to invented worst-cases |
| 00:59 | technomancy | so branch-level coverage is obviously really hard without compiler hooks |
| 00:59 | amalloy | technomancy: robert hooke might be good for that though? |
| 00:59 | technomancy | but var level coverage is trivial |
| 01:00 | technomancy | I think you'd need a cinc compiler to hooke conditionals |
| 01:00 | amalloy | no, i mean for var-level |
| 01:00 | technomancy | oh yeah, sure |
| 01: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" |
| 01:00 | technomancy | actually since you don't need it to compose it's just alter-var-root |
| 01:01 | amalloy | fair enough |
| 01:01 | technomancy | I guess your version is also a lot easier to run from something like clojars |
| 01:01 | amalloy | right |
| 01:01 | technomancy | but... I don't think coverage is actually useful unless you've also confirmed tests pass |
| 01:02 | technomancy | so before any knowledge about the test suite can be considered valuable, you pretty much have to run it |
| 01:02 | amalloy | technomancy: (a) don't really agree |
| 01:02 | amalloy | (b) tests won't all run on clojars anyway. the db server you're testing against won't be installed |
| 01:03 | technomancy | for applications, probably not. but for oss stuff most of them probably would. |
| 01:03 | technomancy | any sql test suites should be able to run against an in-process derby |
| 01:03 | amalloy | technomancy: aleph-redis? |
| 01:04 | technomancy | sure, there are libs with external system-level dependencies |
| 01:04 | technomancy | but they're the minority |
| 01: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 |
| 01:05 | amalloy | a library with 80% of its public vars having at least *some* tests is way better than a library with no tests at all |
| 01:05 | technomancy | yeah, I mean to a degree you can trust the author |
| 01:05 | hiredman | *shrug* |
| 01:06 | hiredman | clojurebot: tests |are| <reply> meh |
| 01:06 | clojurebot | In Ordnung |
| 01:06 | technomancy | turning clojars into free CI is probably not a sustainable approach anyway |
| 01:06 | technomancy | I'm just curious about it because apparently CPAN pulls it off |
| 01:08 | technomancy | I keep trying to rope in newcomers looking for a project to clojars, but it doesn't seem to stick. |
| 01:08 | technomancy | maybe with ato returning from his MIA status there's a chance |
| 01:09 | dakrone | technomancy: is there a todo? |
| 01:09 | dakrone | totally easier to work from a project with a todo |
| 01:09 | technomancy | dakrone: just a mailing list thread iirc |
| 01:10 | technomancy | http://groups.google.com/group/clojars-maintainers/browse_thread/thread/d4149ec96316d5b1 |
| 01:10 | technomancy | actually plenty of enhancements on https://github.com/ato/clojars-web/issues too |
| 01:11 | technomancy | problem is the install instructions don't work for the SCP service out of the box |
| 01:12 | hiredman | need a java scp service |
| 01:13 | technomancy | maybe we can swing it as a seajure hack project |
| 01:14 | hiredman | http://mina.apache.org/sshd/ |
| 01:14 | technomancy | also need to get pjstadig to finish procrustes |
| 01:15 | technomancy | hiredman: huh... wonder if that was stable when clojars was created |
| 01:15 | hiredman | "SSHD provides a CommandFactory to support SCP that can be configure in the following way:" |
| 01:15 | technomancy | sick logo |
| 01:15 | hiredman | maybe not |
| 01:21 | hiredman | 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 |
| 02: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? |
| 02:16 | grant__ | i'm using vim and vimclojure |
| 02:44 | amalloy | $google raek executor clojure binding |
| 02:44 | lazybot | [brehaut.net] http://brehaut.net/links/ |
| 02:44 | amalloy | wth |
| 02:45 | amalloy | grant__: http://blog.raek.se/2011/01/24/executors-in-clojure/ |
| 02:48 | grant__ | wow, whenever i come in here you help me out |
| 02:48 | grant__ | i feel like i owe you something :P |
| 03: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 |
| 03:36 | triyo | 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. |
| 03:36 | triyo | Showdown though is defined and its an object.. |
| 03:37 | triyo | Now I'm trying to do something like...showdown (js* "Showdown") .... (.makeHtml (.. showdown (.converter)) txt)) |
| 03:38 | triyo | Anyone have a clue what the code should look like in cljs? |
| 04:08 | lobotomy | morning folks |
| 04:09 | lobotomy | 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++; } |
| 04:11 | lobotomy | (my use case there is to just create a unique human-readable "name" for each thing to help with debugging) |
| 04:13 | amalloy | lobotomy: ##(doc gensym) |
| 04: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__'." |
| 04:16 | lobotomy | amalloy, awesome, cheers |
| 04:17 | ohwow_ | Also: (def incr (let [x (ref 0)] (fn [] (dosync (ref-set x (inc @x)))))) |
| 04:17 | ohwow_ | ,(def incr (let [x (ref 0)] (fn [] (dosync (ref-set x (inc @x)))))) |
| 04:17 | clojurebot | #<Exception java.lang.Exception: SANBOX DENIED> |
| 04:17 | ohwow_ | uh |
| 04:19 | amalloy | ohwow_: no offense but i'm gonna throw up, there |
| 04:19 | amalloy | (a) an atom would do fine here, there's no need to synchronize multiple refs; (b) you're looking for alter, not ref-set |
| 04:26 | ohwow_ | okay, sorry |
| 04:26 | ohwow_ | i am a clojure newbie |
| 04:26 | amalloy | i know. don't take offense; i'm pointing it out so you'll know how to improve |
| 05:17 | Pupeno | Anybody awake? |
| 05:26 | dedeibel | zzzZZzzz |
| 05:30 | dedeibel | »you will find out that dedeibel was only a watermellon with a wig and an old cassette recorder making sleeping noises« |
| 05:31 | ampleyfly | I will look forward to that |
| 06: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) |
| 06:11 | Pupeno | maybe work on clooj. |
| 06:12 | Pupeno | Any other ideas? |
| 06:15 | djpowell | just playing with clojurescript - is there anyway to include additional javascript files to be processed by the closure compiler? |
| 06:16 | djpowell | i've created a closure template, and can't figure out how to call it from clojurescript |
| 07:00 | laker | hey, what's the best way to handle thousands of connections with clojure? |
| 07:02 | _ato | laker: as in TCP sockets? or HTTP? or...? |
| 07:03 | laker | yeah, tcp |
| 07:04 | laker | and it needs to be async |
| 07:04 | laker | 1 agent per client going to work? |
| 07: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 |
| 07:05 | _ato | you really need select() which is available through nio http://download.oracle.com/javase/6/docs/api/java/nio/channels/Selector.html |
| 07:05 | _ato | it's not very easy to use unfortunately though |
| 07:06 | laker | yeah i saw that, but i was thinking if there was an easy way |
| 07:06 | laker | using the clojure primitives |
| 07:07 | laker | kinda want to use clojure instead of erlang and doing 1 process/client with erlang is great |
| 07:10 | _ato | Aleph might be relevant: https://github.com/ztellman/aleph |
| 07:10 | _ato | I haven't played with it so can't give an opinion on it |
| 07:10 | laker | i'll check it out, thanks |
| 07:39 | problem | (defmacro m [b] `(do ~@b)) |
| 07:39 | problem | (defn t [& b] (m b)) |
| 07:40 | problem | got "Don't know how to create ISeq from: clojure.lang.Symbol" |
| 07:40 | problem | I can't figure it out, can anyone explain that to me? thx |
| 07:41 | jcromartie | problem: you are trying to unquote paste (~@b) a symbol |
| 07:41 | jcromartie | ~@ takes a sequence and puts its contents directly into the macro... so |
| 07:41 | clojurebot | @ has nothing to do with whether sth is evaluated or not |
| 07:42 | jcromartie | (m b) tries to use the symbol 'b as a sequence |
| 07:42 | jcromartie | (defmacro m [& b] `(do ~@b)) is probably what you mean |
| 07:43 | jcromartie | then b is going to be a sequence of each argument to m |
| 07:44 | problem | jcromartie: thanks for the explanation, but what if i want to pass a sequence to a macro from inside a function? |
| 07: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. |
| 07:49 | jcromartie | problem: maybe you are looking for "apply" ? |
| 07:49 | jcromartie | what's your goal, problem |
| 07:50 | jcromartie | problem: what kind of code are you trying to write |
| 07:52 | problem | I am writing something a bunch of functions that use a macro, the functions must take arbitrary arguments. |
| 07:53 | jcromartie | OK :) |
| 07:54 | jcromartie | well, do you understand how to use & ? |
| 07:54 | problem | sure i do |
| 07:54 | jcromartie | k |
| 07:54 | jcromartie | and apply? |
| 07:54 | problem | yes i do |
| 07:54 | jcromartie | (defmacro m [& args] `(do ~@args)) (defn f [& args] (apply m args)) |
| 07:55 | problem | that solves the problem, thank you very much |
| 07:55 | ohwow_ | could you do (defmacro m [a] `(do ~a)) and (defn f [& args] (m args)) ? |
| 07:56 | jcromartie | herp |
| 07:56 | jcromartie | actually |
| 07:56 | _ato | macros can't be applied |
| 07:56 | jcromartie | yeah |
| 07:56 | jcromartie | thanks _ato |
| 07:56 | jcromartie | I think we're back to solving the wrong problem, though |
| 07:56 | ohwow_ | macros could not be used as HOF |
| 07:57 | ohwow_ | So, would my code work? |
| 07:57 | _ato | well, except http://richhickey.github.com/clojure-contrib/apply-macro-api.html |
| 07:57 | _ato | but that just uses eval |
| 07:57 | jcromartie | OK but for our friend problem here |
| 07:58 | jcromartie | problem: your name makes parts of this conversation quite ambiguous |
| 07:58 | _ato | hehe |
| 07:58 | problem | :) |
| 08:00 | _ato | I don't think there's a good way to do it except to rewrite the macro as a function |
| 08:04 | problem | so does that mean it is generally better to define a macro calling functions instead of to define functions calling macros? |
| 08: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 |
| 08:08 | problem | that makes sense |
| 08: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") |
| 08: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 |
| 08:10 | ejackson | anybody seen this ? |
| 08:12 | triyo | ejackson: I know why |
| 08:12 | ejackson | groovy |
| 08:12 | triyo | its a bit different to clojure way of calling methods ion instances |
| 08:13 | triyo | ejackson: https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure look at the Host interpo section |
| 08:13 | ejackson | you may be my new hero ! |
| 08: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 |
| 08:14 | ejackson | checking this out... |
| 08:15 | triyo | From Clojure -> ClojureScript thats a one common gotcha I'd say so far |
| 08:15 | ejackson | triyo: thanks dude ! that worked out |
| 08:15 | triyo | you welcome |
| 08:16 | ejackson | its been fun getting the Library gui stuff going |
| 08:51 | triyo | Does "slurp" function work with relative paths too? |
| 08:51 | triyo | I have a web app that slurps a content of a file and I wish to only provide the relative path. |
| 08:53 | triyo | However, what is the best way to get the relative path and also what is the relative path based on? |
| 08:53 | triyo | classpath or the location of the file that slurp is ran in/ |
| 08:53 | triyo | ? |
| 09:04 | ejackson | triyo: dunno, sorry, no karma payback :( |
| 10:35 | ejackson | 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 | fmw | goog.dom.getElement("slug").value = "foobar"; |
| 11:59 | fmw | (.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 | fmw | 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 | the-kenny | :foo translates to ï·'foo |
| 12:17 | the-kenny | 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 | the-kenny | \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 | the-kenny | (keyword? :foo) returns false in my project :( |
| 12:23 | the-kenny | I'll try re-bootstrapping my ClojureScript |
| 12:25 | the-kenny | 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 | the-kenny | 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 | the-kenny | (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 | the-kenny | 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 | Blackfoot | 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 | the-kenny | 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 | the-kenny | 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 | Blackfoot | 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 | the-kenny | Server-Side will most likely use compojure in the future, but it's currently only a single html file |
| 13:01 | the-kenny | 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 | the-kenny | 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 | TimMc | and for databases, for that matter. |
| 14:05 | peteriserins | TimMc: Heroku, perhaps? |
| 14:06 | peteriserins | 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 | TimMc | 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 | Scriptor | 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 | TimMc | This is just an experimental thingy. |
| 14:18 | Scriptor | then both heroku and GAE should be fine |
| 14:18 | TimMc | hmm, OK |
| 14:20 | TimMc | 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 | jweiss | 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 | jweiss | eg (def blah (atom {:this "hi" :that (promise)} |
| 14:42 | danlarkin | yeah you can deliver to the promise "outside" of the atom |
| 14:43 | danlarkin | (let [a (atom (promise))] (deliver @a :foo) @a) |
| 14:43 | danlarkin | ^ 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 | jweiss | 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 | jweiss | p |
| 15:11 | jweiss | did i do the hint wrong? |
| 15:12 | jweiss | i did (def x (.submit *pool* ^Callable (fn [] "hi there"))) |
| 15:12 | jweiss | 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 | goodieboy | 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 | technomancy | it's a little different and requires emacs 24 |
| 15:44 | goodieboy | ah ok. yeah i'm using master now |
| 15:45 | goodieboy | 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 | goodieboy | thanks |
| 15:47 | technomancy | I'm keen on finding a maintainer for the ruby portion of the starter kit v2 though |
| 15:47 | technomancy | 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 | lobotomy | (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 | sritchie | 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 | amalloy | 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 | lobotomy | 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 | amalloy | 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 | jweiss | ie, (.get (.submit *pool* ^Callable (fn [] "hi"))) |
| 18:46 | jweiss | returns nil |
| 18:46 | amalloy | jweiss: is pool hinted also? |
| 18:47 | amalloy | 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 | jweiss | 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 | jweiss | still returns nil |
| 18:49 | jweiss | 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 | jweiss | i thought that was for me :) |
| 18:52 | jweiss | 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 | jweiss | (let [^Callable f (fn [] "yo")] (.get (.submit ^ExecutorService *pool* ^Callable f))) |
| 18:54 | jweiss | 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 | jweiss | works without the 2nd one |
| 18:55 | jweiss | according to clojure type hint docs, you can hint an expression |
| 18:55 | jweiss | 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 | jweiss | 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 | jweiss | i'm on clojure 1.2 |
| 19:02 | jweiss | 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 | jweiss | 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 | jweiss | 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 | st3fan | 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 | amalloy | (.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 | duck1123 | 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 | st3fan | 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 | JoelMcCracken | 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 | st3fan | i just hit C-c C-c right? |
| 19:49 | st3fan | 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 | st3fan | so i have (ns hello.core) on top |
| 19:51 | st3fan | 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 | st3fan | 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 | mefesto | 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 | st3fan | 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 | duck1123 | 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 | duck1123 | couple hours |
| 20:16 | duck1123 | I'm just now writing my script, did my template conversion over the past week |
| 20:32 | duck1123 | 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 | duck1123 | looks like it's hapening in the else block of ISeqable |
| 20:37 | duck1123 | should I be following master, or should I stick to "stable" builds if there are any? |
| 20:47 | duck1123 | for the record (dorun (for [i (range (alength elements))] (aget elements i))) did the trick |
| 20:47 | duck1123 | not as natural as doing simply (doseq but it'll do |
| 21:11 | st3fan | is org.clojure/java.jdbc decent? |
| 21:11 | st3fan | 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 | st3fan | oh wait it moved to clojure.contrib? |
| 21:24 | st3fan | i grabbed this from org.clojure/java.jdbc |
| 21:25 | scottj | sounds fine |
| 21:34 | amalloy | st3fan: it moved *from* contrib |
| 21:36 | amalloy | 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? |