#clojure logs

2011-12-17

00:00amalloyjcromartie: (proxy [Foo] [] (someMethod [] (.redraw this)))
00:00jcromartiethis!
00:00jcromartieof course
00:00jcromartiethanks
00:01TimMcOK, turns out the CLJS compiler will not write to an existing file. >_<
00:09TimMcbut now there is a sort of cljs REPL on k.timmc.org:7013
00:10TimMcno client support yet -- but (+ 1 2) works
00:16davekongThe clojure spec says that when Integers becomes to large they will automaticall be converted to BigNums but (use 'clojure.contrib.math) (expt 999 999) and I get an overflow error?
00:33davekongclojurebot expt
00:39notostraca2&(doc expt)
00:39lazybotjava.lang.RuntimeException: Unable to resolve var: expt in this context
00:39notostraca2,(doc expt)
00:39clojurebotGabh mo leithscéal?
02:05mrevili don't understand the purpose behind the necessity of deftest, why not just testing "…"?
07:46BorkdudeWhat is the most idiomatic way to get true or false out of (some pred coll) instead of nil?
07:59raekBorkdude: run it through 'boolean': (some (comp boolean f) coll)
08:01raekor if 'pred' is a set, you can use 'contains?' as the function instead of 'get' or the set itself
08:03Borkduderaek: ah ok
08:45VinzentHello. I'm trying to use clojure.core.cache, but (cache/fifo-cache-factory 10 []) gives me "Assert failed: (map? base)". Why? I don't want a map, I want just a collection of values. Can somebody please explain me how to use this library?
08:51janissaryXjk
09:02jasperlaanyone here used xmpp-clj? it doesn't seem there's a way to initiate a chat, right?
09:57Vinzentwhat's with clojureql.org?
09:58tscheiblseems like it's standing still... isn't it?
10:01Vinzenthm, I can't open it (unknown host)
10:01tscheiblI can... but maybe it's cached in my DNS
10:02tscheiblyou are right...
10:02tscheiblit was only cached in my browser
10:05Vinzentlooks like it isn't mainained now at all... well, looking at korma
10:06tscheiblI had a look at Korma, too... but stayed with clojureql... improving it by myself
10:07tscheiblKorma is a bit too much ORM for my taste....
10:08Vinzenthave you considered forking it?
10:08tscheiblI've cloned it locally
10:09tscheiblwhen I find some time I will eventually push my changes to a github fork
10:10tscheibl... I've integrated a slightly modified version of bendlas' "with recursive" improvements
10:11tscheibland added the possibility to use non parameterized (inline) predicates... which is usefull with the "with recursive" construct.. at leas with H2 DB
10:13tscheibl..yes.. and I can use sql functions now with update queries... useful for example to increment a revision count within an update query
10:14tscheiblbtw, clojureql is still online on github
10:15Vinzentyeah, I agree it feels like orm, and for my case clojureql would be a better fit, but you know, docs and all that stuff - probably it'd be easier and faster with korma...
10:15accelis there a simple way in clojure ot get a dump of all threads in the current jvm?
10:17Vinzentthat's cool! you should definitely push it to the main repo
10:21tscheibl@accel: not in core ... I'v used Java interop utilizing the Thread and ThreadGroup classes to implement this
10:21acceltscheibl: do you have a short snipplet of code you can paste bin?
10:22tscheiblaccel: let me see...
10:22accelawesome :-)
10:26tscheiblaccel: damnit .. didn't commit it into the repo...
10:27tscheiblbut basically you have to get your current thread using (Thread/currentThread)
10:27accelis it like: http://stackoverflow.com/questions/1323408/get-a-list-of-all-threads-currently-running-in-java ?
10:27tscheiblyep
10:28accelnoted; thanks
11:10accelcan someone point me at a guide for doing blind, stupid line by line trannslation of java into clojure?
11:10accel[I'll fiure out how to clojure-ify it after I get it working]
11:12nickikaccel, there is no guild. You'll have to look at the clojure-java interop stuff.
11:12Vinzentnew Class() becomes (Class.), obj.method becomes (.method obj), cls.static() becomes (cls/static), that's all
11:12nickikYou will find lots of examples in the internet
11:13accelhow about new Class (foo)
11:13acceldoes it beomce (new Class foo) ?
11:13nickik(Class. foo)
11:13Vinzentyes, or (Class. foo)
11:13accelcls.static(foo, bar) -> (. cls static foo bar) ?
11:13Vinzent(cls/static foo bar)
11:14accelVinzent: nice; thanks
11:14acceldoes clojure have osmethig like lisp's let* ?
11:16TimMcaccel: let
11:17TimMcamusingly, let* is like lisp's let
11:17TimMcbecause it is the more basic form that let uses.
11:18TimMc&(let [x 5, x (+ x 2)] x)
11:18lazybot⇒ 7
11:18accellol; clojure does not give a damn about lisp specs
11:18TimMcaccel: That confused the hell out of me until I re-read http://clojure.org/lisps
11:19TimMcClojure is a Lisp, but it is not Common Lisp.
11:19TimMc&((fn [x x x] x) 1 2 3)
11:19lazybot⇒ 3
11:19TimMc^ fn binds sequentially as well
11:22tscheiblaccel:
11:22tscheibl(defn root-thread-group []
11:22tscheibl (loop [thread-group (.getThreadGroup (Thread/currentThread))]
11:22tscheibl (let [parent-group (.getParent thread-group)]
11:23tscheibl (if parent-group
11:23tscheibl (recur parent-group)
11:23tscheibl thread-group))))
11:23tscheiblthis gives you the root thread group in clojure
11:23TimMctscheibl: *cough* gist *cough*
11:23tscheiblsry
11:24acceltscheibl: nice; thanks :-)
11:25acceldo I need to import something to be able to say (foo/bar) instead of (. foo bar) ?
11:25tscheibl(foo/bar) denotes a static method call
11:27tscheiblbut you could use the (.bar foo) sugar to abbreviate calls to instance methods
11:28Vinzentaccel, you need to import to be able to say e.g. Baz/static instead of foo.bar.Baz/static, this is just like in java
11:28accelnoted
11:28accelfixing things up :-)
11:31accelwoot; I think it kinda worked
11:31accelthanks everyone
11:32tscheiblaccel: you could even replace the let and if lines with (if-let [parent-group (.getParent thread-group)] ...) to gain one line of code :)
11:32tscheiblI mena... to save one line...
11:32tscheiblmean
11:35accelis there a good documentation of "all the things clojure changed from standard lisp/scheme?"
11:36tscheiblaccel: http://clojure.org/lisps
11:36acceltscheibl: awesome; thanks!
11:39cgrayis there a version of with-open that can handle being read from lazily?
11:40cgraysorry, that's not too clear... i want to put a java.io/reader in a with-open, and then read from the reader lazily
12:11accelI have a basic cojure GUI (basically http://clojure.org/jvm_hosted). I have another piece of clojure code that renders to a graphics 2d environment. Question: How do I create a graphics 2d environment?
12:11accelI have a basic cojure GUI (basically http://clojure.org/jvm_hosted). I have another piece of clojure code that renders to a graphics 2d environment. Question: How do I create a graphics 2d environment (within the GUI I have; i.e. what gui element do I want? i.e. something of the type JLabel, JButton, ... but not quite, maybe somethging like JGraphics2D)
12:13accelhmm, JPanel followed by a getGraphics
12:13accel?
12:13accelsurely there is a less hackish way
12:23tscheiblaccel: why don't u use something like https://github.com/daveray/seesaw for GUI development? ... there is another one on github.. I forgot the name...
12:24tscheiblahh yeah.. that one: https://github.com/stathissideris/clarity
12:24clojureboteg, https://github.com/clojure/tools.logging is the new version of clojure.contrib.logging
12:27accelas it turns out
12:27accelall I literally need
12:27accelis a graphics 2d environment
12:27accelto render graphics stuff to
12:33TimMcaccel:Something like this? https://github.com/timmc/CS4300-HW3/blob/master/src/timmcHW3/gui.clj#L179
12:35accelTimMc: not sure yet
12:35accelI just threw in a JPanel; now trying to get stuff to render to it
12:36TimMcaccel: Just proxy a JComponent.
12:36TimMcoverride the paint method.
12:36cgrayaccel: if you don't need buttons and stuff, you might want to look at clj-processing
12:38accelmuhahaha
12:38accelgot it working :-)
12:38accelclj-processing soudns cool though :-)
12:38accelTimMc: ended up I think, doing the equiv of proxing a jpanel
12:39TimMccool
12:39TimMc"you think"? :-P
12:39acceli'm famliar with neither java nor clojure
12:39accelI have noi dea what I've done, but it works :-)
12:39TimMchaha
12:39TimMcaccel: You'll want to read up on the Swing event loop at some point.
12:40accelthis is the "learn a programming language by picking a project + trying to make it work" approach
12:40TimMcIt's not too complicated, and it's important to know.
12:40accelyeah; I need to understand how the separte GUI thread
12:40acceland what I'm allowed to do in what thread
12:40TimMcaccel: https://github.com/timmc/CS4300-HW3/blob/master/src/timmcHW3/core.clj#L557 Check out what launch does and how it is invoked from -main.
12:41accelwhat is this
12:41acceland how are you taknng a CS class
12:41accelwhere the HW is done in clojure
12:41acceland why is your CS HW publically abailable on github? :-)
12:42TimMcIgnore all the ref-set stuff, just note that the frame is created from an invokeLater.
12:42TimMcaccel: Computer Graphics course at Northeastern University. The prof said any language was fine. :-)
12:43TimMcHe also OK'd putting the stuff on GitHub -- I don't remember if I put it up after the assignment was over, or because it's an honor system, or what.
12:49TimMcaccel: I also managed to get permission to use Clojure for my Computer Architecture course.
12:51TimMcIn the REPL, how do I switch over to another namespace and have all the defs refer'd?
12:54tscheiblrefer to the previous namespace?
12:55TimMcNo, refer all the new defs, as if I had started the REPL there.
12:55tscheiblthe defs you did before switching?
12:56TimMcNo, the defs in the new namespace.
12:56TimMcI mean, I could (use 'other.namespace)...
12:59tscheiblsounds good
13:00tscheibl(in-ns 'namespace-name) should also work if the namespace is already loaded
13:01TimMcoops, in-ns takes away core...
13:01TimMcI think I'll stick with use.
13:01TimMcARGH NON-DETERMINISTIC CODE
13:02tscheibl^^
13:02TimMc"Assert failed: Can't recur here" -- and then the next time I call it, no problemo
13:03tscheibllol
13:05tscheibl.. just catch the first exception and retry :D
13:10TimMcugh, seriously.
13:10TimMcI think I'm going to add that to the startup code. >_<
14:19duck1123what projects would anyone recommend to look at that are extensively tested in Midje? (aside from midje itself)
14:40accelis there a program where I can feed it a collection of *.Java files
14:41acceland it'll pull out all the constructors for me?
14:41accelI have a huge java library and I need to interface with clojure
14:55qbgaccel: Maybe using reflection on the classes themselves might be better
15:29blakesmithIf I have a sequence of integers that represent a right single quote in UTF-8 (http://www.fileformat.info/info/unicode/char/2019/index.htm), what's the easiest way to convert that to a string?
15:30blakesmithTrying with no success. https://gist.github.com/1491274
15:30blakesmithI think I'm missing something obvious. :-(
15:36qbgblakesmith: Try using String(byte[], Charset) instead
15:36tomoj`have to get bytes somehow
15:37tomoj`but they're signed..
15:37blakesmithI found out Java doesn't support unsigned bytes. :-(
15:37qbgDoesn't matter
15:37qbgYou need to cast them to byte
15:38tomoj`.. manually? :)
15:38qbgclojure.lang.RT has a method for the cast
15:38tomoj`&(byte 0xE2)
15:38lazybotjava.lang.IllegalArgumentException: Value out of range for byte: 226
15:38blakesmith&(byte 0x99)
15:38lazybotjava.lang.IllegalArgumentException: Value out of range for byte: 153
15:38tomoj`oh, nice
15:38qbgYeah, byte doesn't work
15:38tomoj`hmm
15:38tomoj`you mean byteCast?
15:38qbgThere is an unchecked byte cast method on clojure.lang.RT
15:38qbgI forget the name of it though
15:39tomoj`I get the same error
15:39tomoj`ah, uncheckedByteCast
15:39qbg,(clojure.lang.RT/uncheckedByteCast 226)
15:39clojurebot-30
15:39qbgYep
15:39qbgThere we go
15:39tomoj`excellent
15:39blakesmithNice. Thanks guys!
15:39blakesmithI'll give it a shot.
15:45blakesmithqbg: Hrm, I'm getting java.lang.IllegalArgumentException: No matching method: uncheckedByteCast (NO_SOURCE_FILE:104)
15:45blakesmithuser=> (clojure.lang.RT/uncheckedByteCast 226)
15:45qbgWhat version of clojure are you using?
15:45blakesmith1.2.1
15:47qbg,(.byteValue 226)
15:47clojurebot-30
15:47qbgTry that
15:48blakesmithCool, got it.
15:50blakesmith,(String. (into-array Byte/TYPE (map #(.byteValue %) [0xE2 0x80 0x99])) "UTF-8")
15:50clojurebot"’"
15:50blakesmithAwesome, must be my terminal.
16:04tomoj`oh.. ##(unchecked-byte 0xE2)
16:04lazybot⇒ -30
16:14raekblakesmith: if you use Mac OS X, java is configured to use the wrong default encoding
16:15raekblakesmith: but (String. bytes charset) and (.getBytes string charset) is the correct way
16:38compmstrWhen setting up a macro (defmacro def-func [name] `(defn ~name [attribs] ... why does it turn attribs into user/attribs and not set it up as the argument to the defined function?
16:40compmstrI end up getting the error: "Can't use qualified name as parameter: user/attribs" when I attempt to use the macro
16:40Bronsathis is because syntax-quote automatically namespace-qualifies vars
16:41Bronsawhat you need to do is to replace attribs with attribs#
16:41TimMcBronsa: Thank you for saying that, Bronsa, for you have saved me from making a stupid suggestion.
16:41TimMc(but not saved me from writing awkward sentences)
16:42BronsaTimMc: haha you're welcome
16:42compmstrThank you, so that makes it so that a symbol stays a local symbol instead of expanding to a namespace?
16:42compmstrer...
16:42Bronsa,`(a)
16:42clojurebot(sandbox/a)
16:42Bronsa,`(a#)
16:42clojurebot(a__106__auto__)
16:42TimMccompmstr: foo# is a gensym -- a symbol will be created for you.
16:42Bronsathat ^
16:42compmstrAh, ok
16:43TimMc&`(fn [x#] x#)
16:43lazybot⇒ (clojure.core/fn [x__15392__auto__] x__15392__auto__)
16:43compmstrI was starting to get around it using (symbol ...), but I thought there had to be a better way
16:43TimMccompmstr: and it will be the same symbol for all instances of foo# in the syntax-quote.
16:43compmstrIs that documented anywhere?
16:44TimMcIt's probably in clojure.org/reader
16:44TimMc(The URL, not a namespace)
16:44Bronsahttp://clojure.org/reader under "Syntax-quote"
16:44gfredericks&`(#foo #foo ~(list `#foo))
16:44lazybotjava.lang.ClassNotFoundException: foo
16:44gfrederickshmm
16:45compmstrThank you very much :)
16:45compmstrI've been mainly using the cheatsheet
16:45TimMcgfredericks: foo# not #foo
16:45gfredericksoh ha
16:45Bronsagfredericks: did you mean foo#?
16:45gfredericksjust saw that
16:45gfredericks&`(foo# foo# ~(list `foo#))
16:45lazybot⇒ (foo__15401__auto__ foo__15401__auto__ (foo__15400__auto__))
16:54TimMcUgh, I just want to give up on this try-cljs thing.
16:55TimMcCLJS is so awkward to work with.
16:55budutalking of CLJS, anybody got the browser REPL working through lein repl?
16:56TimMc1) I can't just make an API call and get compiled code back -- it has to write it to the filesystem, and then I have to read it back in.
16:56TimMc2) The GClosure system has its own notions of where dependencies live, and it isn't very clear what those are.
16:56alexbaranoskyTimMc: I see your commit. Cool.
16:57alexbaranoskyreally busy now, hopefully I can get to TryCljs at some point
16:57TimMc3) I have to jump through hoops to compile all the cljs client libs to JS first.
16:57blakesmithraek: Thanks, what's the easiest way to change it? (I'm on OS X)
16:58TimMcalexbaranosky: I sort of almost have the CLJS client libs loading...
16:58alexbaranoskynice!
16:59alexbaranoskyTimMc: non-technical question - do you think TryClojureScript is a better name, considering the site is targeted at beginners, who will probably have no idea what cljs is?
16:59TimMcalexbaranosky: The first compilation almost always fails with an AssertionError, and then succeeds for every subsequent try.
17:00TimMcalexbaranosky: Sounds good.
17:00alexbaranoskyTimMc: strange... what's the assertion error?
17:00TimMcI don't have it on hand, let me start it back up.
17:00alexbaranoskyTimMc: I'll add the cljs -> ClojureScript idea to the TODO file, and get to it when I have time to play
17:03TimMcalexbaranosky: "recur not allowed here" or something.
17:05TimMcit's in the cljs compiler
17:05alexbaranoskyTimMc: strange. My first thought when you said it failed the first time but not afterward, was maybe that there was some weird timing or ordering issue ----- doesn't seem likely though if the error is coming from the compiler
17:06TimMcIt only happens on the first call, and almost always.
17:06TimMctotally weird
17:06alexbaranoskyare the inputs to the first and second call preceisely the same?
17:07alexbaranoskymaybe one is html encoded and the second one is decoded - shot in the dark
17:07alexbaranoskyI have to go though, ciao
17:07TimMcprecisely
17:07TimMccya
17:08alexbaranoskyTimMc: bug in compiler?
17:09djhworldw
17:11gfredericksdjhworld: x
17:17buduis there a way to get the cljs repl working with slime?
17:18TimMcat least (js* "alert(5)") :-P
17:18TimMc*works
17:30technomancybudu: no; it would be tons of work to get that working.
17:38devngood way to convert 500 to [5 0 0] without a lot of intermediate nonsense?
17:41weavejesterdevn: Are you asking for a good way to do that?
17:41devnweavejester: i am
17:41TimMcdevn: Depends on what you mean by "intermediate nonsense".
17:41devnTimMc: I'm thinking about str -> char -> int, etc.
17:41weavejester(->> 500 str (map #(Integer. %)))
17:42weavejester,(->> 500 str (map #(Integer. %)))
17:42clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: No matching ctor found for class java.lang.Integer>
17:42TimMc&(map #(Integer/parseInt (str %)) (Integer/toString 500 10))
17:42lazybot⇒ (5 0 0)
17:42weavejesterOh, oops
17:43Somelauw##(Integer/toString 500) vs ##(str 500)
17:43lazybot(Integer/toString 500) ⇒ "500"
17:43lazybot(str 500) ⇒ "500"
17:43technomancyit's too bad there's no memfn equivalent for static methods and constructors
17:43weavejesterYeah...
17:43technomancy,((memfn Integer.) "30")
17:43clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: Integer. for class java.lang.String>
17:43technomancy(just checking)
17:44weavejester&(->> 500 str (map #(Integer. (str %))))
17:44lazybot⇒ (5 0 0)
17:44weavejesterI'd kinda like a "coerce" multimethod in Clojure core
17:45TimMcI guess we don't need to worry about bases here -- not likely to get octal by accident.
17:45TimMc&(Integer. "050")
17:45lazybot⇒ 50
17:45weavejesterLike: (coerce 1 String) (coerce "1" Integer)
17:45devnwhat about using mod?
17:45TimMc&(Integer/parseInt "050")
17:45lazybot⇒ 50
17:45devn,(mod 500 10)
17:45clojurebot0
17:45devn,(mod 500 100)
17:45clojurebot0
17:45devn,(mod 500 1000)
17:45clojurebot500
17:45TimMcMaybe something with iterate.
17:46devnhm, yeah
17:46Somelauw,(take-while #(> % 1)(iterate 500 #(/ % 10)))
17:46clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.ClassCastException: sandbox$eval486$fn__489 cannot be cast to java.lang.Number>
17:47SomelauwNevermind, that won't work
17:49Raynes&(->> 500 str (map (comp read-string str)))
17:49lazybot⇒ (5 0 0)
17:49RaynesClose enough.
17:53devnthat's pretty
17:56devn,(#(for [c (str (* % %2))] (- (int c) 48)) 500)
17:56clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: sandbox$eval136$fn>
17:57devn,(#(for [c (str (* % %2))] (- (int c) 48)) 5 100)
17:57clojurebot(5 0 0)
17:57TimMcRaynes: I'm writing this Leiningen deps hook that does a bunch of filesystem manipulation and I find myself wishing for a nice macro that allows me to represent a directory tree and bind names to certain nodes.
17:58RaynesTimMc: That sounds interesting.
17:58devnTimMc: what kind of criteria do you have to work with for the nodes? Could you use some combination of file-seq and info about each node?
17:58devnlike modified time, etc.
17:59TimMcdevn: Just paths.
18:00TimMcLet me show you an example of what is making me want this... https://gist.github.com/1491709
18:00TimMcLook at the defs around line 37 and the let bindings in the fetch-cljs fn.
18:01devnTimMc: ahhh, i see
18:01TimMcI haven't decided what the input form would look like, but I imagine something like match.
18:01TimMcwell, I don't know
18:06RaynesTimMc: I don't know if I'll have time anytime soon to write something like that, but if you end up with something, I'd love to include it in fs.
18:07TimMcRaynes: I plan on writing something, but I wanted to put the idea out there in case anyone else had any thoughts on it.
18:07TimMcI'll let you know if I build something.
18:11TimMcOK, pushed changes, so I can delete the gist. Here's the example: https://github.com/baznex/trycljs/blob/efb14d492b29a9afa60a6dd841eed2500c81cbc7/src/leiningen/fetch_cljs.clj
18:13RaynesTimMc: In case you were wondering why I had that little task for grabbing JS deps, it's because I got sick of tryclojure being listed as a JavaScript project.
18:13TimMchaha
18:13devnRaynes: i found that if you place them under a dir called vendor it seems to ignore them
18:13devnfwiw
18:14RaynesYeah, I know, but meh.
18:14TimMcI think that's what amalloy does.
18:14RaynesI totally likes my way too.
18:14TimMcRaynes: CLJS moves so fast that I want to be able to rebuild it. :-/
18:14devnit's kind of nice when you consider the amount of clojure required is a tiny fraction of the JS in most web projects
18:15devneven for medium-sized clojure web projects
18:15Raynesdevn: That's mostly not true though.
18:15devnRaynes: which part? :)
18:16Raynesdevn: The reason there is such an insane amount of JS is because people include what is essentially a standard library in their project (jquery) and other dependencies.
18:16Raynestryclj's actual application js is fairly small.
18:16RaynesIf you included 4clojure's dependencies in the repo...
18:18devnRaynes: it would be interesting to compare a couple of full clojure libs with a project as well as the js libs it needs and see how they stack up
18:21devnhow big is an unminified version of jquery lately?
18:22devn9,266 uncompressed
18:28Raynesamalloy: OHai!
19:02mrevilIf I fork a clojure library, is there a way I can pull it in as a lein dependency without pushing it to a maven repo?
19:05ihodesis there a nice way of changing how toString works on clojure.lang.PersistentQueue?
19:05Raynesmrevil: Check out Leiningen's subproject dependencies.
19:06RaynesYou can also just do 'lein install' to install it in your local maven repo, where it will be usable from other projects like normal dependencies but only on your machine. You don't have to push it to an remote maven repo.
19:06TimMcand there are checkout-deps
19:06TimMcfor a tight development loop
19:06RaynesTimMc: I think that's what I meant by subproject dependencies.
19:07RaynesI've still got cake on the brain.
19:07TimMcOh good, I thought I had missed a mechanism.
19:09mrevilcheckout dependencies may work, I can add the library that I'm hacking on as a git sub-module
19:09mrevilthanks!
19:09amalloyihodes: no
19:10Raynesihodes: You can write your own print method that will make Clojure print it prettily.
19:11TimMcor convert it into a pretty-printing data type
19:11ihodesRaynes, amalloy: yeah, that's not ideal though. i wonder what i was thinking... i could have sworn there was something i could do so calling str on a queue would work nicely...
19:11ihodesTimMc: what do you mean?
19:12TimMcMan, how do you even make them?
19:13TimMc&(into clojure.lang.PersistentQueue/EMPTY [1 2 3])
19:13lazybot⇒ #<PersistentQueue clojure.lang.PersistentQueue@6b58d153>
19:13TimMc&(vec (into clojure.lang.PersistentQueue/EMPTY [1 2 3]))
19:13lazybot⇒ [1 2 3]
19:14ihodesTimMc: ah that's what yo mean, haha. yeah, that's not ideal
19:15amalloyvec is expensive
19:15amalloy&(seq (into clojure.lang.PersistentQueue/EMPTY [1 2 3]))
19:15lazybot⇒ (1 2 3)
19:15ihodes&(time (seq (into clojure.lang.PersistentQueue/EMPTY [1 2 3])))
19:15lazybot⇒ "Elapsed time: 0.7737 msecs" (1 2 3)
19:15ihodes&(time (vec (into clojure.lang.PersistentQueue/EMPTY [1 2 3])))
19:15lazybot⇒ "Elapsed time: 0.462153 msecs" [1 2 3]
19:16TimMcihodes: You're not going to get a meaningful benchmark that way.
19:16RaynesIt's meaningful to him. Let him be.
19:16Raynes:p
19:16devn+1 :)
19:16ihodesTimMc: i know, just curious if there was an order of magnitude difference :) it wont' work for me anyway.
19:17TimMc1) Run it 10000 times to get HotSpot going, 2) make sure to walk both colls, 3) man, lazybot is like the worst benchmark platform.
19:17TimMcihodes: If there is an order of magnitude difference, you're not going to see it that way.
19:17ihodesoh #2 is something i forget all too often.
19:17TimMcsame here
19:18TimMc"Oh man, I can compute an infinite sequence of values in .003 seconds! Clojure ROCKS!"
19:18ihodeseither way... there's no way to ... use something like `proxy` and improve on PersistentQueue.... hmmm damn
19:18RaynesTimMc, ihodes: He is very correct about lazybot not being a good benchmarking platform. clojail molests the the code and such.
19:19amalloyTimMc: but the point here is *not* to walk both colls. calling vec is eager and copies the whole thing even though you don't need to; seq is O(1) and gives you a sequential view from which to create your string
19:19TimMcAlso, lazybot (and its computer) has other concurrent tasks.
19:20TimMcamalloy: I guess you have to ask it for the number of results you would in a real situation.
19:20TimMcihodes: Forget everything that's been said -- if you need to know, benchmark the difference *in place* in your application. :-)
19:21ihodeshaha, i really don't need to either way--I think i'm good
19:22TimMcamalloy: Hey, maybe you know the answer to this -- why is the CLJS compiler file-oriented?
19:22amalloyTimMc: fwiw, just timed calling str on (vec q) and (seq q) on a 1M-element queue. vec is about 33% slower (in what is still not a very good benchmark)
19:22amalloyman i don't know anything about cljs
19:22TimMcYou were a recent committer, so I bugged you.
19:23amalloybut it's my impression that you can get it to output javascript to the repl. i saw chouser doing something like that at the conj
19:23TimMcYou see what happens?
19:23TimMcYeah, but can *I*? He's a wizard or something.
19:25amalloyTimMc: fwiw i just committed an impl of subvec, which really only required converting java to clojure - the cljs aspect was pretty minimal
21:14TimMcOK, found it: analyze and emits.
21:18TimMcThinking back on the binding vs. lazy-seq thing... I guess that even if a lazy-seq call could capture the current bindings for later (and there weren't any other concerns), you wouldn't necessarily want to hold onto those objects.
21:33accelis ther esomething like ";" but coments out an entire region instead of a single line?
21:34TimMcThere's #_ for entire forms
21:34accelhttp://stackoverflow.com/questions/1191628/block-comments-in-clojure
21:34accelwtf
21:34acceldoes that really work?
21:35accelah, #_ is a reader macro?
21:35accelnice
21:35gunsaccel: I've got a vim macro that wraps current form with (comment)
21:35gunsworks nice
21:42sirvalianceDoes lein have any sort of hot code reloading type features? For doing web dev, if would be nice not to have to restart the server everytime.
21:43accelerr
21:43accelI have a confession to make
21:43accelI think I have fallen in love with the repl
21:44technomancysirvaliance: you can either work with a swank/nailgun/nrepl server and reload from your editor or use the wrap-reload middleware (which is ring-specific)
21:45sirvaliancetechnomancy: Checking out wrap-reload now. Thanks
21:45acceldumb question: how can I attach an action listener to a JFrame?
21:45acceli.e. anytime when a key is pressed inside this JFrame,
21:45accelI want an event triggered
21:50amalloy$google java keylistener jframe
21:50lazybot[swing - Java KeyListener for JFrame is being unresponsive? - Stack ...] http://stackoverflow.com/questions/286727/java-keylistener-for-jframe-is-being-unresponsive
21:53weavejestersirvaliance: If you're using lein-ring, it should automatically reload modified files.
21:54weavejesterSame for Noir, if memory serves.
21:55sirvalianceweavejester: Hi! I was just running lein run -m appname.web. First day actually building something with clojure. I will checkout lein-ring. Thanks
21:59weavejestersirvaliance: There's a page on the Ring wiki about different ways of doing interactive development in Ring
21:59weavejestersirvaliance: https://github.com/mmcgrana/ring/wiki/Interactive-Development
21:59sirvalianceweavejester: Oh awesome, I missed that :)
22:00sirvalianceWhat do you all recommend for template rendering? I am fond of pythons django/jinja style templating (inheritance, simple html files, etc).
22:02sirvalianceAlso, what would be the best way to open files to render them, (some-template-render (slurp "some-template.html"))?
22:02sirvalianceOr is there a better way to manage template directories. None of the tutorials or examples seem to go there.
22:04TimMcsirvaliance: Enlive is one approach to templating, although I'm not exactly thrilled with the paucity of API docs.
22:04sirvalianceI like clostache, and I don't know how I feel about hiccup
22:04sirvalianceTimMc: Enlive as well, not to interesting...
22:06sirvaliances/to/too
22:07weavejesterClostache looks most like Django's templates...
22:07TimMcI like the theory behind Enlive, but it's a bit hard to use.
22:07TimMcOnce you have working Enlive code, though, it's pretty easy to read.
22:07weavejesterI also have comb, which is essentially a Ruby erb clone.
22:08weavejesterI've been meaning to use it for creating project skeletons.
22:10duck1123are there any good clojure libs for modifying clojure source files?
22:10TimMcI think I'm going to have to abandon work on try-clojurescript for now -- I just don't understand some of the compilations I'm getting back.
22:11scottjduck1123: I'm guessing the fs lib by Raynes has an rm command :)
22:11TimMcThere's some real impedance mismatch between GClosure and the REPL model. :-/
22:12tmciverTimMc: I just start getting into the trycljs code and now you're going to abandon it? :(
22:12TimMctmciver: For now, at least.
22:12TimMcCLJS is pretty fast-moving though, so it may not be very long until I'm back in it.
22:12Raynesscottj: Indeed, it does.
22:13TimMctmciver: And other folks may continue hacking on it.
22:13duck1123scottj: I'm looking to make a code generator. adding requires to namespaces, adding lines in a form, adding functions to the end, etc
22:13TimMctmciver: (comp/emits (comp/analyze {} '(def x 1))) gives me ".x = 1;\n"
22:13tmciverTimMc: well, I'm going to continue to look at it, for a little while anyway. I know almost nothing about cljs.
22:13TimMcWell, same here!
22:14tmciverTimMc: you're so modest!
22:14TimMctmciver: But I'll keep the site running and updated: http://k.timmc.org:7013/
22:14scottjduck1123: no clue, maybe slamhound has something that might help an itsy bit
22:14tmciverTimMc: already there.
22:14sirvalianceI am going with clostache for now. I am rewriting an app from django to clojure. Don't want to rewrite all of the html
22:16TimMcduck1123: The tricky thing is to preserve the surface syntax, like #(foo).
22:18duck1123mostly I'm looking to append new functions and create files if they don't exist, nothing too heavy
22:18sirvalianceBack to rendering templates from files, what would be the best way to do it? Is slurp appropriate?
22:18technomancy_sirvaliance: slurp on clojure.java.io/resource
22:19technomancy_that way it doesn't matter whether you're running from a project checkout or a jar/war file in deployment
22:20sirvaliancetechnomancy_: Ahh, ok
22:22TimMcOh hey, that's good to know.
22:23Raynessirvaliance: Don't use clostache.
22:23RaynesUse stencil.
22:23RaynesClostache is terribly broken and non-spec compliant.
22:24Rayneshttp://github.com/davidsantiago/stencil
22:24weavejesterThere's a spec?
22:24Raynesweavejester: Yesterjester.
22:25Raynesweavejester: Clostache breaks on basic examples.
22:25weavejesterAhh
22:25Rayneshttps://github.com/mustache/spec
22:25sirvalianceRaynes: Will do, thanks!
22:26sirvalianceRaynes: It caches and loads templates :)
22:27TimMcOh man, I'm so excited -- for the first time, I actually have a *reason* to benchmark one of my programs and tweak the performance.
22:28TimMcUnfortunately, it's in Python, and I have a lot to learn about performance stuff in that language.
22:49TimMcYES! 40x speedup.
22:58accelVars makes sense to me. Refs = trnsactions, I think. Why do I ever want Agents/Atoms?
22:59technomancy_accel: atoms are just less fancy
22:59technomancy_they're your vanilla reference type
23:00TimMcNon-coordinated single-writer, yeah?
23:00TimMc(That's probably a terrible way of characterizing it, sorry.)
23:00RaynesI wish it was clearer what that meant to the uninitiated.
23:03TimMcaccel: atoms are thread-safe boxes you can hammer on, but they don't provide for coordination of multiple bits of state. refs give you true transactional capabilities -- you can hammer on more than one at a time and have guaranteed coordination of updates.
23:03amalloyaccel: if you think vars make sense but you don't understand atoms, you're probably wrong about vars too
23:04amalloyatoms are really a lot simpler than vars: a single mutable pointer to an immutable value. you can change what value they point to in a thread-safe way, but not in a "transaction-y" way
23:07TimMcamalloy: What happens if you swap! an atom while in a dosync that has to be retried?
23:07amalloythen you'll swap! it a few more times
23:07amalloychanging it every time: no transaction safety
23:08TimMcOK, so it's a "side-effect" sensu dosync.
23:08amalloy$dict sensu
23:08lazybotamalloy: Word not found.
23:08TimMcbut agents are safe to hammer on in a dosync, yeah?
23:08TimMcamalloy: "in the sense of"
23:08amalloyyes, send doesn't actually do anything until the current transaction (if any) completes
23:10amalloyokay, finally understood what you meant by "in the sense of" here. yes: swap! should be treated with as much care as any side effects, when inside a transaction
23:11accelis there a way to just read the value of a ref
23:11accelwithout using a dosync?
23:11amalloy@
23:11acceloh
23:11accelI'km an idiot
23:12accelcan I also simplify the following 3 lines?
23:12accel (dosync
23:12accel (let [o @curline]
23:12accel (ref-set curline (str o (.getKeyChar e)))))
23:12accelbasically I'm saying "append this one char to this ref"
23:13TimMc&(doc alter)
23:13lazybot⇒ "([ref fun & args]); Must be called in a transaction. Sets the in-transaction-value of ref to: (apply fun in-transaction-value-of-ref args) and returns the in-transaction-value of ref."
23:13hiredman~alter
23:13clojurebotalter is always correct
23:13TimMcamalloy: Do you know of a more idiomatic way of getting a snapshot of multiple refs than (let [[x y] (dosync [@x @y])] ...)?
23:14amalloy(dosycn (alter curline str (.getKeyChar e)))
23:14amalloyno, i don't. i don't really use refs that often, but that looks like the best solution, TimMc
23:15TimMcI guess one could make a macro (with-snapshot [x y] ...)
23:15amalloywait, except yours might not work, TimMc
23:16amalloyyou might need to use [(ensure x) (ensure y)]? i'm not really clear on the difference between ensure and @
23:16amalloyhiredman can probably tell us if i'm totally wrong
23:16TimMcI think I don't need ensure since I'm not modifying anything.
23:18TimMc&(doc ensure)
23:18lazybot⇒ "([ref]); Must be called in a transaction. Protects the ref from modification by other transactions. Returns the in-transaction-value of ref. Allows for more concurrency than (ref-set ref @ref)"
23:18accelcool cool cool
23:18accelI am happy with this
23:18accelvery very good
23:18accelnow, for even better
23:19accelis there a way in java graphics to render high quality vector graphics/
23:19accelis this done with the graphics 2d api, or something else?
23:19accelby high quality, I want anti aliasiing, and all that neat stuff
23:19TimMcEnsure is to prevent "write skew", IIRC.
23:19TimMcaccel: For anti-aliasing you can turn on some Graphics2D options.
23:20amalloyyeah, it's like setRenderingHint or something
23:21TimMcamalloy: Here's a great explanation of where ensure is needed: http://clojure.higher-order.net/?p=50
23:23amalloyyeah, i've read it. i just use refs so rarely, and ensure never, that it doesn't really click/stick
23:23amalloyand then i go around recommending cargo-cult ensures, apparently, just in case
23:27accelare these objects: (svgGraphics2D) http://xmlgraphics.apache.org/batik/using/svg-generator.html viewable as GUI elemnts?
23:29accelcool cool i'm almost there
23:29accelso I need a blinking timer
23:29accelI'm using awt/swing
23:29accelwhat is the right way to do this?
23:29accelshould I set a timer
23:29acceland constantly flip the value of a string?
23:32TimMcaccel: Use a timer from util or whatever.
23:33amalloyseems like changing the value of a string is crazy, just change the color of something