#clojure logs

2011-07-24

00:06amalloydo we have a print-stack-trace function somewhere? ie, like .printStackTrace but respecting *out*
00:09amalloyappparently it's in clojure.stacktrace. shocking
00:36hiredmananyone used http://code.google.com/p/reflectasm/? I wonder if there are any glaring problems with it, might be nice faster replacement for java reflection in clojure.lang.Reflector
00:37hiredmanclojure's repackaging of asm is kind of a drag here
00:42amalloyhiredman: do source files full of tab characters count as glaring problems?
00:43hiredmannot if I don't have to edit them
00:43metajackIs there a clj->js in Clojurescript? I'm trying to pass a map to a JS library
00:44hiredmanbut I guess I would if I wanted it to use the asm that comes with clojure :/
00:52amalloyhiredman: i don't know a lot about classloaders, but i've heard that one basic rule is "you must delegate to your parent classloader before trying to do something yourself", and if you don't things will have mysterious problems. i notice that the reflectasm doesn't do that
00:53gstampanyone use durendal.el? I'm wondering how to set the default port.
00:57gstampnevermind. I think I have it sorted out
00:58hiredmanClassLoaders: They're Funky
00:58amalloysrsly
01:01hiredmanI think reflectasm's classloader is only ever used to load the generate class that calls the methods
01:01hiredmanit's interesting that the whole thing weighs in so small
01:02hiredman(not counting asm I guess)
01:03amalloyhiredman: it tries to do some funky stuff like setting all methods accessible if it can
01:03amalloyi mean, i imagine it works. but reflectasm breaks the only rule i actually remember, and it also overrides a method that the javadoc for classloader says they'd prefer you not override
01:04amalloyso i'd want to do some research before using it
01:04hiredmanright
01:05hiredmanI am not too concerned, I mean given the shuffling around clojure already does with classloaders
01:54metajackAny idea what this error could mean in cljs? Exception in thread "main" java.lang.IllegalArgumentException: No implementation of method: :-compile of protocol: #'cljs.closure/Compilable found for class: nil
02:49antares_hi
02:49antares_how do I address an inner Java class?
02:49antares_for example, in a package x.y I have classes A and B. How do I address B?
02:52antares_the answer is, first import x.y.A$B and then use A$B, per JVM conventions
02:52antares_nice
02:52amalloythat's not...what...conventions?
02:53antares_well, it is an "enforced convention" ;)
02:53amalloythe class's name *is* A$B
02:53antares_amalloy: right
02:53antares_amalloy: it is still a convention, how inner classes are named
02:54amalloythat it's an "inner" class is mostly invented by javac, and i strongly suspect that the name A$B is guaranteed by the spec, not a convention
02:55antares_amalloy: you are right. I believe the spec does define this naming scheme.
03:02amalloyantares_: found http://www.coderanch.com/t/324724/java/java/Where-inner-class-naming-scheme, fwiw. interesting reading
03:03antares_amalloy: ah, right. That's why I remember it, I read the whole JVM spec but the JLS was too boring for me :)
03:05amalloyi'll bet
03:05amalloythough i learned relatively recently that foo(a(), b()) is guaranteed to call a before b, which is not that case in many languages
03:08hiredmanthe jvm is sort of odd compared with other stack based languages in that regard
03:11amalloyhiredman: is being stack-based correlated? C, for example, doesn't make that guarantee
03:11amalloyi think it's more about the java language than the jvm
03:15hiredmanamalloy: doing it the way the jvm does means you have to kind of box method calls
03:16hiredmanpush target, push arg1, push arg2, call target.invoke(2)
03:16hiredmanvs. something like
03:17hiredmanpush arg2, push arg1, push target, call.invoke(2)
03:18amalloyhmmmm
03:19hiredmanthe two are not actually all that different if you just treat everything as a static method with the target as the first arg
03:20hiredmanthe big difference is having the pushing of the target coincident with the invoke instruction can make code generation easier
03:22hiredmanhuh, OCaml does right to left too
03:23hiredmanC on x86 could be considered stack based, I mean, there are barely any registers involved
03:23hiredmanoh, I misread that sentence, OCaml leaves it unspecified
05:01hiredmananyone using clojure.java.jdbc with derby? getting an exception when trying to run insert-records
05:03hiredman#<SQLException java.sql.SQLException: Only executeBatch and clearBatch allowed in the middle of a batch.>
05:30neotykGood morning everyone!
07:04ahrimani want to do (map #(my-fn %) [(all-records)]) (all-records is a fn that conj maps) and my-fn is a fn that doing smth like (defn my-fn [data] (gen-td (get data :link). But i gets ex #<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn>. What should i do?
07:08raekfirst, "#(my-fn %)" is the same as "my-fn"
07:09raekcan you see which line the exception comes from? if you entered it through the repl you might not. then you can do (require 'your.ns :reload) and the code will have line nunbers
07:09raekahriman: ^
07:10raekalso, the [(all-records)] looks suspicious. are you sure it shouldn't be just (all-records)?
07:10raek(assuming all-records returns a collection of things you want to map my-fn over)
07:11raekahriman: oh, and to get the stacktrace, enter (.printStackTrace *e) into the repl, if you use a bare repl
07:12raek(the IDEs usually provide a more convenient or automatic way to do this)
07:13ahrimanraek that's great, [(all-records)] was the issue! Thank u for such a detailed answer!
07:26swarmer_abwhat is the best way to get two biggest (possibly equal) numbers from vector?
07:28ahrimanraek no, nothing is great. getting ex "NullPointerException". something wrong with this.
07:28ahrimanand clojure.lang.LazySeq@3784b96 on a webpage on a place where output should be.
07:29ahrimanbut bare repl evaluates these fns with output as it should be.
07:32raekwould sorting it in descending order and taking the first 2 elements yield the correct answer?
07:33swarmer_abisn't it very slow if the vector is big?
07:33raekahriman: that is because you try to serialize the datastructure with str and not with pr-str
07:34ahrimanraek str is using only in my-fn function, is it no good?
07:34raek,(str '("this looks like" "five words"))
07:34clojurebot"(\"this looks like\" \"five words\")"
07:34raekhrm.
07:34raek(pr-str ["foo" "bar"])
07:34raek,(pr-str ["foo" "bar"])
07:34clojurebot"[\"foo\" \"bar\"]"
07:35raekahriman: it depends on what you want to turn into a string
07:36raekif you want to stringify clojure data, then you want quotes arount strings etc. (str a-string) will not have the quotes, so you need pr-str in that case
07:36ahrimanraek my code is http://paste.org.ru/?msxdqw
07:36ahrimanmaybe there are some missing parentheses its ok.
07:36raekwhat type does gen-td return?
07:37tufflax,(map (juxt pr-str str) ["abc" [1 2] {:a "a"}])
07:37clojurebot(["\"abc\"" "abc"] ["[1 2]" "[1 2]"] ["{:a \"a\"}" "{:a \"a\"}"])
07:37ahrimanit returns html code string
07:37raek,((juxt pr-str str) (lazy-seq [1 2 3]))
07:37clojurebot["(1 2 3)" "clojure.lang.LazySeq@7861"]
07:38ahrimanreplacing str with pr-str results in "clojure.lang.LazySeq@fa1b87ff" =)
07:38raekahriman: but then you should not get "clojure.lang.LazySeq...."
07:38raekuse 'str' to concatenate two strings
07:38ahrimanhttp://paste.org.ru/?hf3baw there is code for gen-td.
07:38raekif you get "clojure.lang.LazySeq...." then one of the arguments is not a string, but a sequence
07:38tufflaxoh, i've been using str for serializaton so far, but not had problems with it yet :P
07:38ahrimanmaybe there is an error in my logic.
07:39raektufflax: you should use pr-str and read-string
07:39tufflaxyeah now i know :)
07:39ahrimanstrange thing is that in repl all is ok.
07:40raekahriman: I think the problem is in some peice of code you did not post
07:40raekfor example the handler function in your web app
07:41ahrimanhm. other code is route and that's only related code to this webpage. (GET "/" request (pages/gen-rating)).
07:42raekah
07:42raek(map gen-record (all-records))) <-- this returns a sequence
07:42raekand html calls str on it
07:43raekyou probably want (apply html (map gen-record (all-records))))
07:43raekso the error was not in gen-records
07:43raek*-s
07:44raekahriman: ^
07:44ahrimanCan't take value of a macro: #'hiccup.core/html .
07:45leo2007Anyone develops for Android using clojure?
07:45raekhrm, do you even wrap the content in any html elements?
07:46raekthis is why you should not write a macro if a function could do the job, folks
07:47leo2007Is it ready for serious projects?
07:48raekahriman: try this: (html (into [:p] (map gen-record (all-records)))))
07:48raekthat might not work if 'html' tries to do the work at macro expand time
07:49ahrimanraek thanks, it works.
07:49ahrimangenerates rating as it should be.
07:50raekyou might want to read more about how you are supposed to do this things with hiccup. I don't use the library, so my suggestion might not be very ideomatic
07:52ahrimanraek thank u. and last question - what is exactly going on with this code and why simpple (map ...) doesn't work but with apply and into all is OK?
07:55tufflaxswarmer_ab not very slow, it's O(n log n) (or maybe it could be a little better with a lazy sort) but you need O(n) of course. But maybe you could do something like this...
07:55tufflax,(reduce (fn [prev new] (take 2 (sort > (concat prev [new])))) [] [1 29 9 4 10])
07:55clojurebot(29 10)
07:55antares_hey guys. How do I do "continue" in the try/catch block in Clojure?
07:58ahrimanand why there is such html code http://paste.org.ru/?tr9cr2 with so much slashes??
07:58tufflax,(reduce (fn [prev new] (take 2 (sort > (conj prev new))) [] [1 29 9 4 10])
07:58clojurebotEOF while reading
07:58tufflax,(reduce (fn [prev new] (take 2 (sort > (conj prev new)))) [] [1 29 9 4 10])
07:58clojurebot(29 10)
07:58tufflaxmaybe better
08:00swarmer_abthanks
08:04kumarshantanuHi
08:05the-kennyAny tips on how to integrate clojurescript into a leiningen project? I need something like :dependencies [[clojurescript ..]] and "lein clojurescript" :)
08:05kumarshantanuIs there a way to set! a private variable in a Java object?
08:05the-kennyI know it's very early, but nonetheless
08:05raekahriman: I just read the readme for hiccup (https://github.com/weavejester/hiccup) it says that: "If the body of the tag is a seq, its contents will be expanded out into the tag body. This makes working with forms like map and for more convenient."
08:05raekso you are supposed to write [:p (map ...)]
08:07raekahriman: well, it looks like hiccup is not built to accept sequences at this place: (html <here>)
08:07ahrimanraek ok, but what about slashes? it leads to spmething like 1" " 2" " 3" ".
08:10ahrimanso all of attributes of html tags are going away.(
08:13raekahriman: so why? because you are not using the library as the authors indended to.
08:13raekahriman: backslashes?
08:13ahrimanyep
08:14raekyou want to have a \ character in a string?
08:15ahrimanno, i want to render it adequately, not as i mentioned above (with many of ") and with attributes, because not all, but many attributes of html tags are dissapeared
08:19raekahriman: I'm sorry. I don't understand what result you get.
08:21raekall you said was that slashes in some way "leads" to this sequence of strings (with unmatched quotes): 1" "<tab character>2" "<tab character>3" "
08:21ahrimanraek http://disk.tom.ru/rfgyeku/1/ab82a/Clipboard-1.png
08:21ahriman. \"title"\ is what i get as a link.
08:23ahriman<a href=\"link2\" .
08:23raekalso, did you revert the pr-str back into str?
08:23ahrimanomg, not.
08:23ahrimanthanks, now all is ok.
08:23raek(cause it turned out that using str instead of pr-str was not the issue)
08:24ahrimani don't even thought that pr-str can invoke such a problem.
08:24ahrimannow every morning i will study two or three functions from api.
08:25raekit is used to serialize clojrue data. strings will have quotes and quotes inside them will be scaped
08:25raek*escaped
08:25ahrimanah, understand.
08:26raek"clojure.lang.LazySeq...." is a common symptome of using str instead of pr-str, but in your case something else was the problem
08:26raekand str was correct
08:29ahrimanis it possible to develop commercial applications with clojure? this is a question that asks my chief/
08:30raekthere is nothing in the language that stop you from doing it :)
08:30raekbut your boss is probably looking for something like this http://dev.clojure.org/display/community/Clojure+Success+Stories
08:31ahriman10x :)
08:39tomojahriman: possible? demonstrably so.
08:46gfrlogif I created a record one of whose fields is a reference type, have I violated the entire spirit of records?
08:46gfrlogs/created/create
08:46lazybot<gfrlog> if I create a record one of whose fields is a reference type, have I violated the entire spirit of records?
08:48tomojnot necessarily. it's not necessarily a good idea either :)
08:48raekgfrlog: not more than if you would put a reference inside an ordinary map, IMHO
08:48raekthe record is still a persistent container
08:49gfrlogit's not even for threaded things. I just want mutable state :/
08:49gfrlogfor some reason this particular problem is making me think only of classic OOP solutions
08:50raekif state is essential to the application, then by all means use the reference primitives
08:51gfrlogyeah I'm probably worrying too much
10:04triyoI'm having a strange problem with ClojureScript when calling the goog.net.XhrIo/send static method. Here is my code: https://gist.github.com/1102641
10:05triyoMy callback function is an anonymous Clojure function that looks like this: #(dom/replaceNode (dom/htmlToDocumentFragment (.getResponse (.target %))) essay-el))
10:07triyoThe strange result is that the response from (dom/htmlToDocumentFragment (.getResponse (.target %))) is a String: "function (){try{return this.a&&this.a.response}catch(a){return E(this.e,"Can not get response: "+a.message),i}}"
10:08triyoIt just seems to be an unevaluated JavaScript function. Anyone have an idea why this would happen?
10:10triyoI did check the *returned* payload for the send method execution and it has exactly the right data. (Returned data is an HTML fragment btw)
10:15triyoI'm wander if this is the expected behavior based on that maybe I'm doing some wrong or if it is a bug.
10:15triyo*wandering
10:43argvaderI may have a noob question - I am a noob with clojure but I get an error running my application if i dont clean first
10:43argvaderi am using lein clean, run
10:44argvaderif i dont clean then i get an ExceptionInInitializerError - anybody seen this?
10:44gfrlogargvader: you have to clean every time even when you don't make any changes?
10:45argvaderyeah
10:45gfrlognope, never seen that. I don't use `lein run` though
10:45argvaderi even get it using compile
10:46theignoratiwhen doing (classname/staticfield) how would I use a symbol instead of staticfield?
10:46gfrlogI could imagine that kind of thing happening if there was something wrong with your project.clj
10:46argvaderok i will look into that
10:46argvaderthanks
10:46gfrlogtheignorati: reflection? :/ what brings you into that sad state of affairs
10:47gfrlog?
10:48theignoratierr I want to pass the name of a field in a static class to a function
10:48theignoratione of these fields: http://download.oracle.com/javase/1.4.2/docs/api/javax/sound/midi/ShortMessage.html
10:49gfrlogif it were me I'd probably pre-process it into a map (using reflection if necessary)
10:51theignoratiright
10:51gfrlog,(.getFields BigInteger)
10:51clojurebot#<Field[] [Ljava.lang.reflect.Field;@da52a1>
10:52gfrlog,(seq (.getFields BigInteger))
10:52clojurebot(#<Field public static final java.math.BigInteger java.math.BigInteger.ZERO> #<Field public static final java.math.BigInteger java.math.BigInteger.ONE> #<Field public static final java.math.BigInteger java.math.BigInteger.TEN>)
10:54gfrlog,(->> BigInteger .getFields seq (map (juxt #(.getName %) #(.get % BigInteger))) (into {}))
10:54clojurebot{"ZERO" 0, "ONE" 1, "TEN" 10}
10:54gfrlogtheignorati: ^ looks like that works
10:54theignoraticheers
10:54theignoratiwhat does ->> do?
10:55theignoratiill read the docs
10:55gfrlogtheignorati: it's a threading macro. e.g., (->> BigInteger .getFields seq) turns into (seq (.getFields BigInteger))
10:56gfrlog,(->> BigInteger .getFields seq (map (juxt #(-> % .getName clojure.string/lower-case keyword) #(.get % BigInteger))) (into {}))
10:56clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.string
10:56gfrlogdang
10:56gfrlogI was trying to turn the keys into lower-cased keywords
10:56gfrlog,(->> BigInteger .getFields seq (map (juxt #(-> % .getName .toLowerCase keyword) #(.get % BigInteger))) (into {}))
10:56clojurebot{:zero 0, :one 1, :ten 10}
10:56gfrloglike that
10:57gfrlogone more expression to replace underscores with dashes and we're golden...
10:58gfrlog,(->> BigInteger .getFields seq (map (juxt #(-> % .getName .toLowerCase (.replaceAll "_" "-") keyword) #(.get % BigInteger))) (into {}))
10:58clojurebot{:zero 0, :one 1, :ten 10}
10:58gfrlogno difference in this case of course
11:02gfrlogtheignorati: this here is a general version: https://gist.github.com/1102703
11:03theignoratithanks :)
11:04gfrlogno probalo
11:36bobnormalhey, what's the ("a" "b" "c") -> "abc" function again?
11:36gfrlogclojure.string/join?
11:36clojurebotyou mean clojure.main
11:37bobnormalta. drives me nuts learning this language, but i love it :)
11:37gfrlog$findfn ["a" "b" "c"] "abc"
11:37lazybot[clojure.string/join]
11:37gfrlogclojurebot: what's wrong with you?
11:37clojurebotNo entiendo
11:37mdeboard,(apply str ("a" "b" "c"))
11:37clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn
11:37mdeboard,(apply str '("a" "b" "c"))
11:37clojurebot"abc"
11:37gfrlog,(apply str ["a" "b" "c"])
11:37clojurebot"abc"
11:37mdeboardthat too
11:37gfrlogbobnormal: so that's a more specific way, if you're not interested in a separator
11:38mdeboard(apply str (interpose ":" ["a" "b" "c"]))
11:38mdeboard,(apply str (interpose ":" ["a" "b" "c"]))
11:38clojurebot"a:b:c"
11:38gfrloghrmph.
11:38bobnormalapply str and reduce str both work, but apply str = less chars .. looks like i just levelled-up in codegolf ;)
11:38mdeboard:')
11:39kephale,(clojure.string/join ":" ["a" "b" "c"])
11:39gfrlogbobnormal: apply might be more efficient too
11:39clojurebotjava.lang.ClassNotFoundException: clojure.string
11:39gfrlogat least it has the potential to be
11:42bobnormalgfrlog: thanks, but i'm FAR too n00b to worry about efficiency yet
11:42gfrlogvery good
11:43kephaleis there a more up-to-date bot in here?
11:43gfrlog&(clojure.string/join ":" ["a" "b" "c"])
11:43lazybot⇒ "a:b:c"
11:43kephalegfrlog: aha, ty
12:14mdeboardI like the string/join syntax better to be honest
12:15ahriman÷¸
12:15devnstop golfing, before golfing stops you. ;)
12:15ejacksonthan devn :)
12:15ejacksons/than/thanks
12:15lazybot<ejackson> thanks devn :)
12:16devnwe have another bot in here now?
12:17devnah, nevermind, sexpbot got renamed
12:29devnWhat happens when you accidentally past some code into your pianobar (command line pandora) client?
12:30devnWell if you're like me, you get a station named "ns a lazy seq of nums from start (inclusive) to end" that is /actually/ Luke Vibert.
12:32ejacksonhe seems to be a snare drum
12:57StayInSkoolhow come set takes in a sequence but sorted-set takes in arguments?
13:22ahrimanusing with compojure 0.6.4 route (GET "/greet/:name" (str "Hello " (params :name))) and receiving error "unsupported binding form". what is it?
13:22ahrimangot code from http://en.wikibooks.org/wiki/Compojure/Core_Libraries
13:28ahrimansolved
14:00maaclHas anyone been able to compile the Convex Hull ClojureScript demo? (http://jng.imagine27.com/articles/2011-07-23-101007_clojurescript_demo_convex_hull.html)
14:08dnolen_anyone know much about AVL trees here?
14:14jcromartiesince it's a wiki book, can we fix it?
14:14grantmi want to start up a webserver in a separate thread, and then have a function i can call to kill that thread. i got as far as (.stop Thread) but apparently that's deprecated and the wrong way to go about it. can someone point me in the direction of the right way?
14:16jcromartie(def server (... code to start server))
14:17jcromartie(.stop server)
14:18grantmbut starting the server will block, so i can't just go (server) in the repl because then i'll never be able to type (.stop server)
14:19jcromartiegeez that wikibooks page on compojure should just be deleted
14:20ahrimanwikibooks is old :(
14:22jcromartiealthough it was originally written by weave
14:22grantm(future (start-server)) is, like, 80% of what i want. i just want something like future-kill
14:30maaclHas anyone been able to compile the Convex Hull ClojureScript demo? (http://jng.imagine27.com/articles/2011-07-23-101007_clojurescript_demo_convex_hull.html)
14:33grantmfound an answer to my problem! for posterity: http://stackoverflow.com/questions/2706044/how-do-i-stop-jetty-server-in-clojure
15:06gfrlogis it plausible that (spit) might not touch the file's timestamp?
15:36maaclgfrlog: no, that is not possible
15:38gfrlogturns out my issue is low resolution on the timestamp (1 sec)
15:50raekI wonder if it would be possible to make a browser plugin that could work as the development environment for ClojureScript
15:50raekso that we can use the browser JS engine instead of Rhino
15:51raekthat way it might be possible to test stuff like paining on a canvas in the dev repl
15:51gfrlogwhat from java does the CS compiler require?
15:52raekthe CS compiler is a Clojure lib
15:52raekso it requires Clojure
15:52raekI was thinking of taking the output from the compiler and send it to the browser
15:52gfrlogperhaps more to the point, is CS-in-CS implausible for some reason, or just a lot of work?
15:53raekinstead of letting Rhino eval the result, let the browser do it
15:54gfrlogjava applet?
15:55raekmaybe the clojure side could start a http server, which the browser can query
15:55ibdknoxjust do it over websockets
15:55gfrlogthat sounds like the easiest route
15:55ibdknoxstream the JS to a page
15:55raekbasically, we just need some communication channel between the compiler and the browser
15:56gfrlogand stream the CS back to the server
15:56ibdknoxyep
15:56ibdknoxit'd be fairly easy to do I would think
15:59hugodswank-js could probably be converted to clojurescript…
16:03qbgI wonder what the CS compiler needs that CS doesn't currently have
16:06gfrlogis the gclosure compiler written in JS or Java?
16:06gfrlogi suppose it's not strictly necessary...
16:06chouserraek: great idea. I've got a cljs compiler-as-a-service nearly ready to go
16:06chousergclosure is a java lib
16:07qbg(inc chouser)
16:07lazybot⟹ 1
16:07gfrlogbut clojurescript doesn't need it, right?
16:07qbgcompiler as a service should in theory make a web-based repl possible
16:08chouserqbg: that's my actual goal
16:08chousergfrlog: correct
16:09qbgJust add a web server to the mix and you could make ajax calls to get the compiled code
16:09chouserI had it working for my old ClojureScript, though with the compiler in an applet rather than on a server.
16:10qbgIt would be like jstestdriver, but the other way around
16:10hugodswank-js uses node.js and socket.io to talk to the browser
16:17qbgIs there any reason why CS doesn't implement the STM for compatibility?
16:18raekjavascript does not have threads
16:19raekwell, maybe some frameworks add support for threads, but it's not in the language as in Java
16:23nickikOne could implment the refs just as atoms that would make it easy to make libs compatibel
16:48grantmis there a builtin for what's in other languages a if/elseif/elseif construct?
16:48alandipertgrantm: see cond and condp
16:49grantmalandipert: hmm... cond isnt exactly what i want - let me see if i can clarify
16:51grantmbetter question: is there an idiomatic way to return the first non-nil form
16:52raekgrantm: or
16:52grantmhaha ... thanks
16:52raek,(or nil nil false 4 "foo")
16:52clojurebot4
16:52grantmyeah
16:53grantmthanks :)
17:00raekis it possible to use the ns form at the repl?
17:16gfrlogconverting a byte-array to a hex-string shouldn't be this hard :(
17:39qbgRich comes up with the best stuff: "ClojureScript is an action movie, and we're interested in helping people kick butt."
17:40technomancydoes anyone have a good solution for gmail killfiles?
17:41technomancyit's easy enough to just blacklist ken wesson and james keats, but replies from non-trolls still get through
17:41amalloytechnomancy: use imap and a mail client with killfiles?
17:41technomancyI guess their name would still exist in the body of the reply
17:41technomancyamalloy: I do, but I read gmail on my phone as well as my laptop
17:41technomancyand I'd like the rules to apply even when my laptop is off
17:41amalloyalas
17:42technomancyapplying the killfile to the body seems a bit excessive, but at this point I'm ready to try it
17:48technomancyaw geez; almost forgot mike meyer
17:54technomancyI just need to be able to rely on other folks to clue me in in the unlikely event that there's a relevant conversation on the mailing list involving them.
17:55amalloytechnomancy: every time i get a message from one of them, i'll forward it to you just in case it's relevant
17:56ejacksoncareful amalloy, i really worry that technomancy could go affect a rule 24 (charlie stross style) if pushed
17:56ejacksonclojure would be a good choice for that :)
17:56ejackson34.... bah
17:58ejacksonftod: http://en.wikipedia.org/wiki/Rule_34_%28novel%29
18:00ejacksonwhat a mess, honestly.
18:10amalloyhuh. i guess i don't understand the macro story for cljs. there seem to be no macros in core.cljs, and it relies on macros defined in cljs/core.clj. are macros not implemented for cljs?
18:11raekI heard from the talk that macros run in clojure
18:11ejacksonditto
18:13mjg123WARNING: Use of undeclared Var bfcoins/defmacro
18:14mjg123which is to say that macros don't seem to work in cljs
18:17amalloyit's too bad rich "wasted" one of his rare appearances on the mailing list for this silly thread
18:42alandipertamalloy: macros are written in clojure
18:42alandipert(there is no cljs defmacro)
18:43hugodI'm not sure if this is useful, but https://gist.github.com/1103191 will let you run the cljs compiler every time a .cljs buffer is saved in emacs
18:43amalloyalandipert: right, but i don't really understand what that means. if i'm writing a cljs app with some repeated code i want to factor out, i have to...somehow step out of cljs and back to clj, to define a macro i can use in my cljs?
18:45glob157Not sure about how "let" works... used to let in python (just offers some output to the calling function) ?
18:45amalloy&(let [x 1] (+ 3 x))?
18:45lazybot⇒ 4
18:46hugoda pom file for cljs https://gist.github.com/1103202, which depends on a jar for the closure-library, which can be built with https://gist.github.com/1103200
18:46glob157so what is the need for the let ?
18:47ejacksonglob157: it provides a scope within which variables are bound
18:47glob157seems unnecessary, why not just declare the variable.
18:47amalloyglob157: that's how you declare a variable
18:47glob157oh ok i think i get it thanx
18:48glob157let is the syntax required for declaring variables INSIDE of a function.
18:48glob157?
18:49glob157seems kind of strange though--- let is kind of verbose , dont you think ? why not just x = 2
18:50glob157instead of let [x 2]
18:50amalloybecause we're writing lisp, not c
18:51amalloy"x = 2" further implies that you could reassign x later, which you can't
18:52glob157@amalloy haha touche (first comment)
18:52theignoratiif you do (let [a 1 b 2 c 3] it's less verbose than c
18:52amalloyplus "x = 2" kinda has to be bounded by punctuation of *some* sort. c uses semicolons for that
18:52amalloypython chooses to make whitespace semantically meaningful, which would be disastrous in an expression-oriented language
18:52glob157for (int i = 0 ; i < s ; i++) {printf("clojure is not C");
18:53mjg123}
18:53alandipertamalloy: right, and your clj file with your macros should be on the compiler's classpath
18:53alandipertamalloy: see https://bitbucket.org/puffnfresh/clojurescript-timeout-cps/src for an example
18:54amalloyah, require-macros. okay, fair enough
19:00mjg123I've a macro, sort of like (time) except it returns the time taken rather than printing it
19:01mjg123the implementation of how to get the current time has to depend on whether I'm on top of JVM of JS
19:01mjg123what's a good way to wrap that up?
19:03grantmis there an easy way to concat two regexes, for example (regex-concat #"a" #"b") => #ab?
19:05amalloygrantm: it isn't really meaningful as a plain concat. someone (cgrand?) has a library for less-terse, more-composable regexes
19:05grantmwhat do you mean by meaningful?
19:05amalloygrantm: suppose the first regex were #"foo|test"
19:06grantmoh i see.
19:06amalloyor had capturing groups
19:06amalloybut https://github.com/cgrand/regex might be what you want; i haven't tried it
19:06grantmthat makes sense
19:06grantmas an alternate solution, is there support for raw strings?
19:07grantmi dont think i need a whole library :)
19:07grantm(at least i hope not... what i'm doing is pretty simple)
19:07amalloysure. java has that
19:07amalloy&(re-pattern (str "a" "b"))
19:07lazybot⇒ #"ab"
19:08grantmright, that's what i switched to
19:08grantmit's a little annoying that i have to change all my \s to \\s but i'll manage
19:08grantm:)
19:09amalloy&(str #"\s")
19:09lazybot⇒ "\\s"
19:09grantmooh. oh neat!
19:09grantmfeels a little hacky..?
19:09amalloywell you're hacking, so...
19:10amalloy$javadoc java.util.regex.Pattern toString
19:10lazybothttp://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html#toString()
19:10grantm(so i guess you can go about concating regexes like (re-pattern (str (str re-1) (str re-2))) ...)
19:10amalloygrantm: the extra strs are unnecessary
19:10amalloy&(re-pattern (str #"\s+" "\d*"))
19:10lazybotjava.lang.Exception: Unsupported escape character: \d
19:10amalloy&(re-pattern (str #"\s+" #"\d*"))
19:10lazybot⇒ #"\s+\d*"
19:11grantmoh cool
19:11grantmthanks!
19:11grantmthat's just what i need.
19:11amalloyanyway, Pattern.toString is defined to return a string that you could compile and get back the same regex
19:12amalloyso if you feel the usefulness outweighs the grossness, knock yourself out
19:12grantmhaha
19:13glob157Is there a less verbose way to create statefull variables than (def/ref) combinations?
19:14glob157(if not, can someone elucidate the added value of the varbosity (i assume this is related to lisp statelessness))
19:15amalloyglob157: stop doing it. you think you need state, but you don't
19:16amalloy(disclaimer: not always true, but always good advice for someone just learning the syntax)
19:17glob157oh, you mean, def/ref are rightfully "salient"... i.e. they aren't supposed to be taken lightly.
19:17glob157or used commonly.
19:17grantmglob157: you may find it useful to explain why you need state
19:17glob157this is helping me.
19:18glob157thanks guys . Its been a while since i did any FP....
19:18glob157State is required for applications with users or outputs.
19:18glob157(just for arguments sake....)
19:19glob157is "alter" also a bad idea ?
19:19amalloyglob157: haskell manages with no stateful constructs at all. clojure is a bit more forgiving
19:19grantmwell, you can get output with println ;) be more specific?
19:20amalloygrantm: well, as the saying goes, a program with no side effects just heats up your cpu
19:20mjg123a warm room is a side-effect :)
19:20amalloyit's not crazy to claim that side effects are a kind of state, though i do think it's clouding the picture for no real goal
19:21grantmthat's true :)
19:23grantmsay i have ["1" "2"] and want to destructure it and parse the ints - is there an idiomatic way to do that?
19:24amalloy&(let [[a b] (for [x ["1" "2"]] (Integer/parseInt x)))
19:24lazybot⇒ nil ; Adjusted to (let [[a b] (for [x ["1" "2"]] (Integer/parseInt x))])
19:24amalloyoh, and then of course you have to use a and b
19:24grantmcool, that makes sense
19:26mjg123Change "Integer/parseInt" to "* 1" if you're in cljs
19:29ejacksonyou thought he was done ?
19:30hiredman,*clojure-version*
19:30clojurebot{:interim true, :major 1, :minor 3, :incremental 0, :qualifier "master"}
19:30hiredmanques
19:31hiredmanI guess it is 'queues'
19:36glob157how come its okay to "nest" code inside of let ? i.e. (let [past-visitor (@visitors username)]
19:37glob157more appropriate question : why does let take two args..? why not just take in the bindings? no need for an expression.
19:38dnolen_fun, strongly terminating purely relational assoc, https://gist.github.com/1102865
19:39amalloyglob157: i think your two questions answer each other?
19:44powrtocIs there an implementation of a sorted vector / array / list datastructure in clojure?
19:44powrtocI know we have sorted-set and sorted-map
19:45ejacksonbollocks, who let it become 1am. i'm off.
19:51technomancyhiredman: cueues?
19:51technomancyerr--cues?
19:56amalloyqueues
19:57powrtocYeah, I guess I really need a priority queue ... are there any persistent ones implemented for clojure yet? What about finger-trees?
19:59pdkhttp://code.google.com/p/jc-pheap/
19:59pdkcontrib also has priority-map
20:04zakwilsonIf I'm not doing load balancing or anything of that sort, is there a good reason to have something like Apache or nginx sit in front of ring/jetty?
20:07amalloyzakwilson: we do that so we can have additional servers running that know nothing about jetty
20:08zakwilsonamalloy: well, yes. Assuming that isn't a consideration.
20:09amalloyyour question seems to summarize as: "assuming there are no reasons to use nginx, is there a reason to use nginx"
20:09amalloy(that is, "anything of that sort" is not defined well enough to answer)
20:10zakwilsonI guess the question is: are there security or performance problems inherent in exposing ring/jetty directly to the web?
20:12seancorfieldlooking at clojure.test it doesn't appear that there's any way for a fixture function to be able to inspect the metadata of an actual test?
20:13seancorfieldi was hoping to be able to annotate tests to allow for optional behavior in the fixture...
20:14hiredmanseancorfield: you can create a test that reruns tests in a different context kind of thing
20:15seancorfieldyeah, i was hoping for something a bit cleaner than that :(
20:15hiredmanwe do something like that combined with test selectors at work
20:16seancorfieldi may end up using test-ns-hook and running the tests that way
20:17seancorfieldor breaking the tests into multiple namespaces
20:17seancorfieldreal shame that fixtures aren't passed the test var as well as the test fn
20:17seancorfieldor at least the :each fixtures
20:17hiredmanlein test selectors
20:18seancorfieldthis has to run in maven - it's clojure.java.jdbc :)
20:18seancorfieldi've repro'd the apache derby failure
20:18hiredmanI've fixed in clojurebot by jsut re-defing the function in question to what I need for derby
20:24powrtocwhat's the best idiom for reduce-until? i.e. I want the reduce to return when a condition is met, and not consume the remaining seq?
20:25seancorfieldgiven that .executeBatch fails on SQL Server and PostgreSQL and .executeUpdate fails on Derby (but works on every other DB tested so far) for that use case makes this a tricky bug :)
20:25Scriptorpowrtoc: maybe a reduce on a take-while?
20:25powrtocScriptor, was just thinking that... hmmm
20:27powrtocScriptor, actually that doesn't work... because it's the accumulation value that I need to test on
20:28powrtocahh I think I can use reductions
20:28powrtocthen test on that
20:28powrtocwith a take-while
20:37amalloyright
20:37amalloyi guess i was afk, but reductions
22:23seancorfieldhiredman: looks like i have a fix for apache derby with clojure.java.jdbc
22:45leedaHi, anyone know what's wrong with this simple function? I get a "java.lang.IllegalArgumentException: Key must be integer" error: https://gist.github.com/5e181362ead42965e1fd
22:45hiredman,([] :foo)
22:45clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Key must be integer>
22:46leedabut user is a map
22:47hiredman*shrug*
22:47leedahm
22:47hiredmansomewhere you are calling a vector as a function with a non-number argument
22:54leedayeah you were right, i found the problem. it was in a different function.
23:14darevayHi. Anyone ever notice slurp adding an extra newline at the end when reading from a resource? Clojure 1.2.0.
23:14hiredmanhave you looked at what you are slurping in a made sure there is no extra newline there?
23:15darevayYeah. It's a single line file with no newline. If I add a newline, then I get two newlines.
23:16hiredmanare you sure?
23:18darevayNo :) I'll try in a smaller test and come back if it's still a problem. Just checking.
23:18hiredmanwhat does wc -l say for whatever you are slurping in?
23:18hiredman0 means no newlines
23:21darevayUser error. For some reason vim betrayed me. Sorry to waste your time.
23:23darevayOn the bright side I learned something new about vim tonight.
23:43technomancycron will screw you over silently if you have files that don't end in newlines
23:56argvaderanybody used the form-dot-clj project?
23:56argvaderi am getting an error and i think its part of a macro within that library but I really dont know macros yet
23:58argvaderis this an ok last statement for a macro `(def ~field-namve ~field)
23:58argvaderit appears to have 2 namespaces when i expand it and i think this might be causing a no matching ctor error